在全站升级https后,突然发现某些接口暂时不能直接重定向。需要时间处理,所以需要在nginx中重定向所有URL中排除某个指定的URL
原始配置:
server {
listen 80;
server_name www.abc.com abc.com;
if ($host != 'www.leftso.com' ){
rewrite ^(.*)$ http://www.abc.com$1 permanent;
}
HTTPS 301
rewrite ^(.*)$ https://www.abc.com$1 permanent;
}
修改后:
server {
listen 80;
server_name www.abc.com leftso.com;
if ($host != 'www.abc.com' ){
rewrite ^(.*)$ http://www.abc.com$1 permanent;
}
location /需要排除的URL地址 {
# 非默认端口需要添加$server_port
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#解决shiro跳转问题
proxy_pass http://localhost:8080;
}
location / {
#HTTPS 301
rewrite ^(.*)$ https://www.abc.com$1 permanent;
}
#HTTPS 301
#rewrite ^(.*)$ https://www.abc.com$1 permanent;
}
原创文章,作者:506227337,如若转载,请注明出处:https://blog.ytso.com/243846.html