nginx 重定向所有之后排除某个url

位置:首页>文章>详情   分类: 教程分享 > nginx教程   阅读(1333)   2023-03-28 11:29:14
在全站升级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;

}
地址:https://www.leftso.com/article/869.html

相关阅读

在全站升级https后,突然发现某些接口暂时不能直接重定向
Linux(centos) nginx安装和nginx入门配置方法1.切换至root用户$su - 2.执行在线安装命令#yum install nginx -y 如果上面提示以下内容[root...
打开任务管理器发现一大堆nginx进程
最近网站被恶意访问了,了解了一些基础防护手段,nginx屏蔽ua访问 编写文件agent_deany.conf #使用方法 #创建目录 /etc/nginx/conf.d/deny [注意]...
最近博客升级总是nginx原生的502页面,感觉有些不友好,特此研究了下502页面的配置nginx 502配置502页面核心配置 #502 page error_p...
解决centos系统使用yum安装nginx启动时报错[::]:80 failed (97: Address family not supported by protocol)一般默认的使用yu...
nginx开启gzip压缩配置配置参考:server{listen443ssl;server_namet.example.com;#charsetkoi8-r;#access_log/var/l...
1.新增nginx屏蔽配置文件文件暂时为/etc/nginx/conf.d/deny_ua.config说明:文件名deny_ua.config,后缀为.config非.conf,原因是.con...
nginx日志默认格式如下:$remote_addr-$remote_user[$time_local]"$request"$status$body_bytes_sent"$http_refer...
nginx 跨域头统一配置 location / { add_header Access-Control-Allow-Origin *; add_header Access-...