Install And Set Nginx For Different Domain To localhost Port
這篇介紹Install And Set Nginx For Different Domain To localhost Port。
Install
1 2
| 在CentOS7上,登入切換root權限 $ yum install nginx
|
How to set
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| $ cd /etc/nginx/conf.d $ touch domain.conf 在檔案domain.conf,新增以下設定:
server { listen 80; server_name david.blog;
location / { proxy_pass http://10.10.10.1:7777; } }
參數說明: listen 從瀏覽器進來的port server_name 設定需解析的domain location 進來後需導至哪一個IP & Port
|
設定完重啟
1 2 3 4 5 6 7 8
| 設定後先檢查設定檔的語法是否正確: $ nginx -t 如果沒有錯誤, 便可以重新載入 Nginx 的新設定: $ nginx -s reload 啟動 Nginx: $ systemctl start nginx 設定開機自動啟動: $ systemctl enable nginx
|