: Nginx proxy rewrite not matching I'm setting Nginx to forward requests to several backend services using proxy_pass A few of them I have to add rewrite rules to strip the folder off, however
I'm setting Nginx to forward requests to several backend services using proxy_pass
A few of them I have to add rewrite rules to strip the folder off, however for this particular service, the rewrite rule isn't working on styles/images. Any tips?
~$ tail /var/log/nginx/error.log
2012/02/09 10:57:19 [error] 4103#0: *10 open() "/var/www/images/blank.gif" failed (2: No such file or directory), client: 203.xxx.xxx.xxx, server: example.net, request: "GET /images/blank.gif HTTP/1.1", host: "example.net", referrer: "https://example.net/hp/"
~$ cat /etc/nginx/proxy-control.conf;
proxy_connect_timeout 59s;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_pass_header Set-Cookie;
proxy_hide_header Vary;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_set_header Accept-Encoding '';
proxy_ignore_headers Cache-Control Expires;
proxy_set_header Referer $http_referer;
proxy_set_header Host $host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header Authorization '';
proxy_redirect example.net/ /;
proxy_redirect example.net/ /;
~$ tail /etc/nginx/services.conf;
location /hp {
rewrite ^/hp$ example.net/hp/ permanent; $
rewrite /hp/(.*) / break;
proxy_pass 192.168.1.2/; include proxy-control.conf;
include auth-basic.conf;
}
chrome errors;
example.net/images/blank.gif Failed to load resource: the server responded with a status of 404 (Not Found) example.net/images/final-hp-login_1x11.gif Failed to load resource: the server responded with a status of 404 (Not Found)
More posts by @Bryan171
1 Comments
Sorted by latest first Latest Oldest Best
I think your settings are incorrect. When there is a request to example.net/images/blank.gif it is sent to 192.168.1.2/images/blank.gif and there will be a 404. Your two rewrites do not match, of course, because this request does not begin with /hp. Maybe you want proxy_pass 192.168.1.2/hp?
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.