Debugging nginx URL rewrite: How do I figure out where the problem is?
Posted
by
pjmorse
on Server Fault
See other posts from Server Fault
or by pjmorse
Published on 2011-04-15T22:01:07Z
Indexed on
2011/11/16
10:00 UTC
Read the original article
Hit count: 227
I have a specific URL pattern on a site which needs to be redirected to the HTTPS version. This is a Django site; Nginx checks each URL in memcached, and if it doesn't find a cached version it proxies the request to Apache/mod_python for Django to render the page.
The relevant configuration block is
rewrite ^/certificate https://mysite.com/certificate ;
rewrite ^/([a-zA-Z]{2})/certificate https://mysite.com/certificate ;
...and it doesn't appear to be working at all.
Nginx is:
$ nginx -V
nginx version: nginx/0.7.65
built by gcc 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
TLS SNI support disabled
configure arguments: --prefix=/usr/local/nginx --pid-path=/var/run/nginx.pid --with-http_gzip_static_module --with-http_ssl_module
How can I figure out if the problem is my patterns not matching, or a more obscure configuration problem?
(The site is localized to three languages, and the localization is in the URL string, e.g. /US/news/
, /DE/about
, etc. It tracks localization in the session as well, defaulting to US, so if you just requested /news
Django will rewrite to /US/news
unless the user has a cookie indicating they're using a different localization. Django handles this, though, not Nginx.)
© Server Fault or respective owner