现在同一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
13
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:4 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐