There's been a few questions like this but the most similar are unanswered and the rest have confounding factors. A deploy of previous-working-fine nginx is redirecting instead of proxying. The relevant section of the nginx.conf looks like this;
location /timesheets/ {
gzip on;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_proxied any;
gzip_min_length 1000;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_buffers 16 8k;
gunzip on;
gzip_static on;
# Disable for IE < 6 because there are some known problems
gzip_disable "MSIE [1-6].(?!.*SV1)";
# Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
gzip_vary on;
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_pass http://timesheetserver.fqdn.com.au:8216$request_uri;
proxy_intercept_errors on;
}
When accessing the server at the URL in the server_name part, they content at timesheetserver on port 8216 should be proxied to them. For some reason it's replying with 302 to the proxy_pass server, and because the users can't access port 8216 it's failing. What would cause this?
UPDATE: It 302's to the proxy_pass server if the index.html is left off the end. It works fine if the index.html is manually appended. I've added an index index.html; directive but it doesn't seem to handle the file being left off – how do I resolve?
Best Answer
It is better that use FQDN(Fully Qualified Domain Name) for reverse proxy than
timesheetserver
.Ref: http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver