Nginx 如何建立多个web服务 使用不同端口

发布时间 2023-10-10 13:29:09作者: Arcturis
   server {
        listen       8080;
        server_name  ip;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;article/list/0/json
        location / {

            if ($request_method = 'OPTIONS') {
                return 204;
            }

            root   html/Web1;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

这假如是原本的 只需要再次建立一个 server模块  修改端口即可

 

   server {
        listen       8081;
        server_name  ip;
  #access_log  logs/host.access.log  main;article/list/0/json
        location / {

            if ($request_method = 'OPTIONS') {
                return 204;
            }

            root   html/Web2;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

完事重启