nginx反代配置tips

nginx轮训导致验证码不正确

在upstream里添加ip_hash;,例子:

http {
    upstream test {
        # 这样同一台电脑会一直访问到同一台机器
        ip_hash;
        server 172.0.0.1:8080;
    }
}

静态资源访问出错

在location里重写header:

server {
    location / {
        index  index.html index.htm;
        proxy_pass http://test;
        # 重写header
        proxy_set_header  Host $http_host;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

To be continued...

本文作者:编程随写

本文链接:https://www.cnblogs.com/code-blog/p/17565936.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   code-blog  阅读(23)  评论(0编辑  收藏  举报
历史上的今天:
2022-07-19 Spring Data Jpa 分表处理
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起