现在同一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
今天的文章linux nginx多端口配置,Nginx(10) nginx 配置多个server,多个端口分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/7401.html