這篇“ubuntu下nginx服務器如何配置”文章的知識點大部分人都不太理解,所以小編給大家總結了以下內容,內容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“ubuntu下nginx服務器如何配置”文章吧。
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; } }
如果還有其他域名和后臺服務器,在目錄下繼續新建對應的域名配置文件即可

以上就是關于“ubuntu下nginx服務器如何配置”這篇文章的內容,相信大家都有了一定的了解,希望小編分享的內容對大家有幫助,若想了解更多相關的知識內容,請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。