ubuntu如何配置nginx服务器?;来看看ubuntu 下的nginx服务器配置详解
1.nginx服务器的安装
sudo apt-get install nginx
2.nginx服务器的启动
sudo /etc/init.d/nginx start
3.多域名对应不同的后台服务器
【ubuntu如何配置nginx服务器】在/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;
}
}
如果还有其他域名和后台服务器,在目录下继续新建对应的域名配置文件即可
推荐阅读
- 个人信用贷款绝如何办理?个人信用贷款申请流程详情介绍!
- 敲诈者病毒VirLocker病毒win10电脑如何防范
- 如何正确开搓饵
- FAST路由器如何设置wifi
- 如何关闭qq浏览器自动打开
- 换车时如何更换etc
- cad指北针如何绘制
- ios怎么屏蔽垃圾信息 ios如何屏蔽信息
- 华为如何检查电池寿命 如何检测华为电池寿命
- 手机声音太小怎么解决? 手机声音太小如何解决