现在同一linux服务器配置其端口的服务,拟用已经运行 的nginx来配置

步骤如下

创建一个配置文件  比如  /usr/local/nginx/sites-available/gaotianyue.conf

upstream gaotianyue.com{
        server 127.0.0.1:8070 weight=1;
    }
    server {
        listen       8071;
        server_name  localhost;

        location / {
            proxy_http_version 1.1;
            proxy_pass http://gaotianyue.com;
            proxy_redirect default;
            proxy_connect_timeout 1s;
            proxy_read_timeout 5s;
            proxy_send_timeout 2s;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            add_header 'Access-Control-Allow-Headers' 'Content-Type';
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET';
        }

        location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|mp3|mp4)$
        {
             root /data/gaotianyue/static_src;
             expires      14d;
        }

         error_page  404   /404.html;
         error_page  404   /404.html;
         location = /404.html{
          root   html;
        }

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

修改nginx.conf

最后一个括号前添加

  include /usr/local/nginx/sites-available/*.conf;
}

然后检查下

[root@VM_126_4_centos nginx]# sbin/nginx -t -c conf/nginx.conf
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

最后重启

sbin/nginx -s reload


GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐