-
配置
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/