Welcome! Log In Create A New Profile

Advanced

Re: disable 301 redirect for directory / use relative redirect / change scheme

August 26, 2015 11:56AM
On 2015-08-26, 8:36 AM, Edho Arief wrote:
> On Thu, Aug 27, 2015 at 12:30 AM, Etienne Champetier
> <champetier.etienne@gmail.com> wrote:
>> Hi,
>>
>> I have this setup
>> browser -> ssl proxy -> nginx
>> browser to ssl proxy is https only
>> ssl proxy to nginx is http only
>>
>> now i browse to "https://exemple.com/aaa", where aaa is a directory,
>> so nginx send back a 301 redirect with "Location: http://exemple.com/aaa/"
>>
>> Is it possible to send https instead of http (in Location),
>> or send a relative header, like "Location: /aaa/",
>> or just disable this redirection (in my case it's ok)
>>
> see if proxy_redirect[1] fits your need.
>
> http://nginx.org/r/proxy_redirect
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
use a rewrite 302 can easy help. If the client cant reach the intended
site (say due to internal network/firewalls) then you can also Proxy the
connection if needed.

here is how the 302 rewrite would look like:
rewrite ^ https://$hostname$request_uri? redirect;

You can also mix this with an if statement in case you only want
"http://example.com/aaa" to be redirected to HTTPS and not everything

example:
if ($host = example.com) {
if ($uri = /aaa/) {
rewrite ^ https://$hostname$request_uri? redirect;
}
}

Something like that, this is untested but should work.
Keep in mind that using IF like this has a performance cost (though
small, it all depends on number of req/site load... something to keep in
mind)

Cheers,
Payam Chychi

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

disable 301 redirect for directory / use relative redirect / change scheme

Etienne Champetier August 26, 2015 11:32AM

Re: disable 301 redirect for directory / use relative redirect / change scheme

Edho Arief August 26, 2015 11:38AM

Re: disable 301 redirect for directory / use relative redirect / change scheme

Etienne Champetier August 26, 2015 11:54AM

Re: disable 301 redirect for directory / use relative redirect / change scheme

Edho Arief August 26, 2015 12:22PM

Re: disable 301 redirect for directory / use relative redirect / change scheme

Etienne Champetier August 26, 2015 12:30PM

Re: disable 301 redirect for directory / use relative redirect / change scheme

unclepieman August 26, 2015 11:56AM

Re: disable 301 redirect for directory / use relative redirect / change scheme

biazus August 26, 2015 12:59PM

Re: disable 301 redirect for directory / use relative redirect / change scheme

ru@nginx.com December 22, 2016 10:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 268
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