proxy_pass strangeness

daveyfx nginx-forum at nginx.us
Thu Oct 7 19:51:20 MSD 2010


Hi all,

I'm having an odd issue in my current configuration. I have nginx on the
front-end, which is handling static content and passing off dynamic
content requests to Apache servers in the back end. I'm having an odd
issue right now with one of my location directives, which performs a
proxy_pass function to an upstream Apache server.

server {
listen *:80;
server_name www.nstein.dev
root /opt/nstein;
access_log off;
error_log off;
index index.php index.html;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;

proxy_pass http://nstein_http_cluster;
}


location /blogs/ {
access_log /tmp/blogs_access.log;
error_log /tmp/blogs_error.log;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;

proxy_pass http://blogs_http_cluster/;
proxy_redirect off;
}


Here's the corresponding entry in the Apache vhost file:

Listen 81

ServerAdmin xxx at xxx.com
DocumentRoot /opt/nstein/static/mte
ServerName nsweb1.nstein.dev
ServerAlias www.nstein.dev

ErrorLog /usr/local/apache2/logs/blog/error_log
CustomLog /usr/local/apache2/logs/blog/access_log combined
DirectoryIndex index.php

RewriteEngine On



The very odd behavior is that if I input a URL into my browser as such,
the page loads fine:
http://www.nstein.dev/blogs/on_call/

However, if I leave out the trailing slash, the server performs a 301
redirect. For instance:
http://www.nstein.dev/blogs/on_call redirects my browser to
http://www.nstein.dev/on_call and throws a 404.

The nginx access log displays the following (snipped down of course):
"GET /blogs/on_call HTTP/1.1" 301 238
And oddly enough, Apache's access/error logs show me nothing. Almost as
if the request never hits Apache.

Any ideas? Thanks for your help!

Dave

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,138173,138173#msg-138173




More information about the nginx mailing list