-
配置
server { listen 80 default_server; listen [::]:80 default_server; server_name :127.0.0.1:8080;
反向代理到本地8080端口,重定向到域名網站home主頁
location / { rewrite ^/$ http://www.xxxx.com/home/ redirect; proxy_pass http://127.0.0.1:8080; }
-
效果
輸入 www.xxxx.com 會跳轉到 http://www.xxxx.com/home/
-
內部邏輯
1、域名 www.xxxx.com 等同於 www.xxxx.com:80
2、訪問80端口會代理到 www.xxxx.com:8080
3、rewrite 重新定向到 http://www.xxxx.com:8080/home/
4、經過代理遮蔽掉8080端口最終顯示的網址 http://www.xxxx.com/home/