源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

ubuntu 下的nginx服务器配置详解

  • 时间:2021-05-03 06:07 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:ubuntu 下的nginx服务器配置详解
[b]ubuntu 下的nginx服务器配置详解[/b] 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;
 }
}
如果还有其他域名和后台服务器,在目录下继续新建对应的域名配置文件即可 [img]http://files.jb51.net/file_images/article/201703/2017031411240915.png[/img] 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部