ubuntu 下的nginx服務(wù)器配置詳解
1.nginx服務(wù)器的安裝
sudo apt-get install nginx
2.nginx服務(wù)器的啟動(dòng)
sudo /etc/init.d/nginx start
3.多域名對(duì)應(yīng)不同的后臺(tái)服務(wù)器
在/etc/nginx/sites-enabled/ 目錄中刪除default配置文件
新建域名對(duì)應(yīng)的配置文件
比如test.youlunshidai.com
#通過upstream nodejs__upstream 可以配置多臺(tái)nodejs節(jié)點(diǎn),做負(fù)載均衡upstream nodejs__upstream__test__youlunshidai { server 127.0.0.1:8089; #服務(wù)器地址和端口號(hào) #server 127.0.0.1:8088; #負(fù)載均衡服務(wù)器地址和端口號(hào) keepalive 64; #設(shè)置存活時(shí)間。如果不設(shè)置可能會(huì)產(chǎn)生大量的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; #反向代理轉(zhuǎn)發(fā) http://nodejs__upstream; }}如果還有其他域名和后臺(tái)服務(wù)器,在目錄下繼續(xù)新建對(duì)應(yīng)的域名配置文件即可

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選