nginx proxypath https redirects to http
Posted
by
Thermionix
on Super User
See other posts from Super User
or by Thermionix
Published on 2011-11-24T01:46:36Z
Indexed on
2011/11/24
1:56 UTC
Read the original article
Hit count: 324
I'm trying to setup Nginx to forward requests to several backend services using proxy_pass however several pages load with 404s
The links on the pages have https://
in front, but result in a http request - which ends in a 404 - I only want these services to be available through https.
I've tried with varied trailing forward slashes appended to the proxypath and location in proxy.conf, I've also tried commenting out www.conf
(just incase its location blocks could have caused any conflicts) to no effect.
So if a link is too https://example.com/sickbeard/errorlogs
in a browser when loaded https://example.com/sickbeard/errorlogs
gives a 404
in a browser https://example.com/sickbeard/errorlogs/
loads
nginx error log;
2011/11/23 14:21:58 [error] 28882#0: *6 "/var/www/sickbeard/errorlogs/recent.html" is not found (2: No such file or directory), client: 192.168.1.99, server: example.com, request: "GET /sickbeard/errorlogs/ HTTP/1.1", host: "example.com"
Config files;
proxy.conf
location /sickbeard {
proxy_pass http://localhost:8081/sickbeard;
include proxy.inc;
}
.... more entries ....
sites-enabled/main
server {
listen 80;
include www.conf;
}
server {
listen 443;
include proxy.conf;
include www.conf;
ssl on;
}
www.conf
root /var/www;
server_name example.com;
location / {
autoindex off;
allow all;
rewrite ^/$ /mainsite last;
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
expires max;
}
location ~ \.php$ {
fastcgi_index index.php;
include fastcgi_params;
if (-f $request_filename) {
fastcgi_pass 127.0.0.1:9000;
}
}
}
proxy.inc
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_redirect off;
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;
© Super User or respective owner