请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

关于windows配置nginx的问题

老师,我的nginx之前前后端联调做反向代理的时候已经改过了,改的有些乱。也找了各种博客之类的,但是还是看不懂并且很懵。能不能说一下具体的配置方法,下面是我之前改过的nginx.conf文件

麻烦您看一下哪里需要改,怎么改


#user  root;

worker_processes  2;


#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;


#pid        logs/nginx.pid;



events {

    worker_connections  1024;

}



http {

    include       mime.types;

    default_type  application/octet-stream;


    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';


    #access_log  logs/access.log  main;


    sendfile        on;

    #tcp_nopush     on;


    #keepalive_timeout  0;

    keepalive_timeout  65;


    #gzip  on;


    server {

        listen       8080;

        server_name  localhost;


        #charset koi8-r;


        #access_log  logs/host.access.log  main;


        #location / {

        #   root   html;

        #    index  index.html index.htm;

        #}


       location / {

proxy_pass http://localhost:5500;

       }


       location /api/ {

proxy_pass http://localhost:8000;

proxy_set_header Host $host;

       }


        #error_page  404              /404.html;


        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }


        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        #location ~ \.php$ {

        #    root           html;

        #    fastcgi_pass   127.0.0.1:9000;

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        #    include        fastcgi_params;

        #}


        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

    }



    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;


    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}



    # HTTPS server

    #

    #server {

    #    listen       443 ssl;

    #    server_name  localhost;


    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;


    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;


    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;


    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

}


正在回答 回答被采纳积分+3

1回答

扬_灵 2022-04-07 08:39:11

同学你好,你可以和课程一样使用include重新指向一个nginx.conf的配置文件,使用新的端口进行配置,这样不会影响之前的配置在启动时会多出 一个端口服务进行使用。

0 回复 有任何疑惑可以回复我~
  • 我也是这个问题,可以再详细说一下吗。到后面就打不开要配置的这个文件(修改三:添加 /Users/sam/upload/upload.conf 文件)-----和课程一样使用include重新指向一个nginx.conf的配置文件:意思是要和Mac配置的操作一样吗
    回复 有任何疑惑可以回复我~ 2022-05-28 17:56:17
  • 同学你好,这里需要你在本地任意位置创建一个.conf的配置文件,在nginx.confg配置文件中使用include指向这个文件路径。
    回复 有任何疑惑可以回复我~ 2022-05-28 21:03:08
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信