Hello,
I am using NGINX as an HTTP proxy, and in some cases, I need to rewrite
all requests from http:// to https://
My proxy configuration has two server {} blocks, one with http, and one
with https
So if my sample configuration looks like: (assume proxy server name is
proxy.com)
server
{
listen 80;
location /
{
rewrite ^/(.*)$ https://proxy.com/$1;
}
}
server
{
listen 443;
…
}
In this case, I think there is a problem with the regex substitution,
because I get a line like:
2008/05/31 15:10:11 [error] 5802#0: *1 rewrite or internal redirection
cycle while processing
“https://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.com/”,
client: 192.168.159.1, server: proxy.com, request: “GET / HTTP/1.1”,
host: “proxy.com”
2008/05/31 15:10:11 [debug] 5802#0: *1 http finalize request: 500,
“https://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.com/?”
2008/05/31 15:10:11 [debug] 5802#0: *1 http special response: 500,
“https://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.comhttps://proxy.com/?”
2008/05/31 15:10:11 [debug] 5802#0: *1 http set discard body
2008/05/31 15:10:11 [debug] 5802#0: *1 HTTP/1.1 500 Internal Server
Error
Server: nginx/0.7.1
Date: Sat, 31 May 2008 09:40:11 GMT
Content-Type: text/html
Content-Length: 192
Connection: close
I’ve tested this with nginx 0.7.1
Any help here would be appreciated
Regards,
Mansoor P.
PS: The redirection works when I use http instead of https
rewrite ^/(.*)$ http://proxy.com/$1;