Welcome! Log In Create A New Profile

Advanced

Re: rewrite to HTTPS?

Guillaume Filion
March 17, 2010 11:04AM
Silly me, should have RTFM:
http://wiki.nginx.org/NginxHttpRewriteModule#rewrite

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

Guillaume Filion a écrit :
> 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;
> }
> }
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx


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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite to HTTPS?

Guillaume Filion March 17, 2010 10:28AM

Re: rewrite to HTTPS?

Guillaume Filion March 17, 2010 11:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 262
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready