Welcome! Log In Create A New Profile

Advanced

rewrite to HTTPS?

Guillaume Filion
March 17, 2010 10:28AM
Hi all,

I'd like to make a rewrite rule to redirect the client to an HTTPS page,
so that a user is redirected from:
http://host.name/p/A2010/TExfDqN5cPi/b7i8UDhqgx3rmXlc+yv+T7hmxuykWGENpg==
to:
https://my.host.name/path/to/profil/?a=A2010&c=TExfDqN5cPi/b7i8UDhqgx3rmXlc%2byv%2bT7hmxuykWGENpg==
but I'm getting a "400 Bad Request" from nginx when I try to send them
to the HTTPS site.

This works (returns a "302 Moved Temporarily"):
rewrite "^/p/([AH][0-9]{4})/(.+)$"
http://my.host.name/path/to/profil/?a=$1&c=$2 break;

This doesn't (returns a "400 Bad Request"):
rewrite "^/p/([AH][0-9]{4})/(.+)$"
https://my.host.name/path/to/profil/?a=$1&c=$2 break;

Could someone shed some light on this?

Thanks a lot!
GFK's

Here's my sanitized config:
server {
listen 1.2.3.4:80;
server_name my.host.name;
proxy_connect_timeout 2;
client_max_body_size 4M;
access_log /var/log/nginx/my.host.name_HTTP.access.log;
error_log /var/log/nginx/my.host.name_HTTP.error.log;

location / {
proxy_next_upstream error timeout invalid_header http_500;
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;

# Profil
rewrite "^/p/([AH][0-9]{4})/(.+)$"
https://my.host.name/path/to/profil/?a=$1&c=$2 break;

proxy_pass http://BACKEND;
}
}

server {
listen 1.2.3.4:443;
server_name my.host.name;
client_max_body_size 4M;
access_log /var/log/nginx/my.host.name_HTTPS.access.log;
error_log /var/log/nginx/my.host.name_HTTPS.error.log;

ssl on;
ssl_certificate /etc/nginx/certs/my.host.name.crt;
ssl_certificate_key /etc/nginx/certs/my.host.name.pem;
ssl_protocols SSLv3 TLSv1; ssl_ciphers
ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP;

location / {
proxy_next_upstream error timeout invalid_header http_500;
proxy_set_header SSL Enabled;
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://BACKEND;
}
}

--
Guillaume Filion
http://guillaume.filion.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
SubjectAuthorPosted

rewrite to HTTPS?

Guillaume FilionMarch 17, 2010 10:28AM

Re: rewrite to HTTPS?

Guillaume FilionMarch 17, 2010 11:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 79
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 229 on August 01, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready