addis_a
November 19, 2014, 1:16pm
1
Hi – we currently have a redirect rule in a location on our server to
redirect all non-SSL traffic to SSL, like so:
location / {
return 301 https://$server_name$request_uri;
}
This works for almost all cases, but there is an edge case that is
broken by
this.
We have a custom subdomain functionality that our users use to give them
more personalised-looking URLs, so they can use .oursite.com
So username.oursite.com should redirect to https://username.oursite.com
And otheruser.oursite.com should redirect to
https://otheruser.oursite.com
Could anyone advise me on what redirect rule I should use to achieve
what
our current rule does (redirects almost all traffic to HTTPS), and also
redirects the special case.
Thanks very much for any and all assistance,
Doug.
Posted at Nginx Forum:
Hi -- we currently have a redirect rule in a location on our server to redirect all non-SSL traffic to SSL, like so: location / { return 301 https://$server_name$request_uri; } This works for almost all cases, but there is an edge case that is broken...
biot023
November 19, 2014, 1:17pm
2
On Wed, Nov 19, 2014 at 9:16 PM, biot023 [email protected] wrote:
more personalised-looking URLs, so they can use .oursite.com
So username.oursite.com should redirect to https://username.oursite.com
And otheruser.oursite.com should redirect to https://otheruser.oursite.com
Could anyone advise me on what redirect rule I should use to achieve what
our current rule does (redirects almost all traffic to HTTPS), and also
redirects the special case.
check $host
biot023
November 19, 2014, 3:22pm
3
Ah, will do, cheers – I had a look through the NGINX variables, but it
wasn’t really clear which variable did what.
I suppose something like:
location / {
return 301 https://$uri ;
}
Wouldn’t work?
Posted at Nginx Forum:
Hi -- we currently have a redirect rule in a location on our server to redirect all non-SSL traffic to SSL, like so: location / { return 301 https://$server_name$request_uri; } This works for almost all cases, but there is an edge case that is broken...
biot023
November 19, 2014, 3:39pm
4
On Wed, Nov 19, 2014 at 11:22 PM, biot023 [email protected] wrote:
Ah, will do, cheers – I had a look through the NGINX variables, but it
wasn’t really clear which variable did what.
I suppose something like:
location / {
return 301 https://$uri ;
}
Wouldn’t work?
generic redirect looks like this
return 301 https://$host$request_uri;
biot023
November 19, 2014, 4:13pm
5
That seems to be just the ticket – thankyou very much!
Posted at Nginx Forum:
Hi -- we currently have a redirect rule in a location on our server to redirect all non-SSL traffic to SSL, like so: location / { return 301 https://$server_name$request_uri; } This works for almost all cases, but there is an edge case that is broken...