当前位置:   首页安装配置主机配置:ubuntu 下的nginx主机配置详解

主机配置:ubuntu 下的nginx主机配置详解

发布日期:2022-03-16 10:18 | 文章来源:源码中国

ubuntu 下的nginx主机配置详解

1.nginx主机的安装

sudo apt-get install nginx

2.nginx主机的启动

sudo /etc/init.d/nginx start

3.多域名对应不同的后台主机

在/etc/nginx/sites-enabled/ 目录中删除default配置文件

新建域名对应的配置文件

比如test.youlunshidai.com

#通过upstream nodejs__upstream 可以配置多台nodejs节点,做负载均衡
upstream nodejs__upstream__test__youlunshidai {
 server 127.0.0.1:8089; #主机地址和端口号
 #server 127.0.0.1:8088; #负载均衡主机地址和端口号
 keepalive 64; #设置存活时间。如果不设置可能会产生大量的timewait
}
server {
 listen 80;
 server_name test.youlunshidai.com;
 access_log /var/log/nginx/test_youlunshidai.log; #nginx日志文件
 location / {
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header Host  $http_host;
 proxy_set_header X-NginX-Proxy true;
 proxy_set_header Connection "";
 proxy_http_version 1.1; 
 proxy_pass http://nodejs__upstream__test__youlunshidai; #反向代理转发 http://nodejs__upstream;
 }
}

如果还有其他域名和后台主机,在目录下继续新建对应的域名配置文件即可


感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

联系我们
关于使用场景和技术架构的更多咨询,请联系我们的销售和技术支持团队。
Yingsoo Host

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部