nginx反向代理禁用缓存
今天遇到一个怪事,nginx+frp反向代理后,很多网站都重定向到了同一个网站,经排查, 是nginx反向代理缓存的过,
于是禁用缓存:
- #PROXY-START/
- location /
- {
- expires 12h;
- if ($request_uri ~* "(php|jsp|cgi|asp|aspx)")
- {
- expires 0;
- }
- proxy_pass http://127.0.0.1:5000;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header REMOTE-HOST $remote_addr;
- #持久化连接相关配置
- #proxy_connect_timeout 30s;
- #proxy_read_timeout 86400s;
- #proxy_send_timeout 30s;
- #proxy_http_version 1.1;
- #proxy_set_header Upgrade $http_upgrade;
- #proxy_set_header Connection "upgrade";
- #add_header X-Cache $upstream_cache_status;
- proxy_cache off;
- #Set Nginx Cache
- add_header Cache-Control no-cache;
- }
- #PROXY-END/