atom feed14 messages in ru.sysoev.nginxRe: Rewriting https to http
FromSent OnAttachments
iane...@public.gmane.orgJan 11, 2007 1:26 pm 
Igor SysoevJan 11, 2007 1:40 pm 
Jonathan DanceJan 12, 2007 3:56 am 
Jonathan DanceJan 12, 2007 4:06 am 
Igor SysoevJan 12, 2007 4:16 am 
Igor SysoevJan 12, 2007 4:32 am 
Jonathan DanceJan 12, 2007 4:33 am 
Jonathan DanceJan 12, 2007 4:40 am 
Igor SysoevJan 12, 2007 4:42 am 
Igor SysoevJan 12, 2007 4:45 am 
Jonathan DanceJan 12, 2007 5:20 am 
Igor SysoevJan 12, 2007 5:35 am 
Igor SysoevJan 12, 2007 6:41 am 
Jonathan DanceJan 12, 2007 6:55 am 
Subject:Re: Rewriting https to http
From:Jonathan Dance (jd-a@public.gmane.org)
Date:Jan 12, 2007 3:56:50 am
List:ru.sysoev.nginx

The order of locaiton processing is described here: http://wiki.codemongers.com/NginxHttpCoreModule#location

As previously mentioned there, the documentation for this (very important) command is quite hard to understand and was in need of attention. So, after much re-reading and using Google translate on the Russian docs, I think I understood it and completely rewrote that section. I would appreciate it if Igor and the other nginx team members could review it to make sure it is correct.

RewriteCond %{SERVER_PORT} ^443$ RewriteCond $1 !^(securedir|2ndsecuredir|3rdsecuredir)/ [NC,OR] RewriteCond $1 !\.(css|gif|jpe?g|bmp|js|inc)$ [NC] RewriteRule ^/(.*) http://www.example.com/$1 [R=301,L]

Igor's example will work but I might recommend folding it into a single regex so you only have a single location block to configure, e.g.:

location ~*
"^(securedir|2ndsecuredir|3rdsecuredir)|\.(css|gif|jpe?g|bmp|js|inc)$" { }

This is slower than using the non-regex versions like Igor did but for me the convenience of a shorter configuration file outweighs the performance hit of a regex call... besides, the regex was going to be called anyway unless you use ^~ (see the docs :) ).

Best regards, JD