http -> https redirection, with a twist?
Brad Knowles
brad at shub-internet.org
Wed Feb 29 03:45:31 UTC 2012
On Feb 28, 2012, at 9:42 PM, António P. P. Almeida wrote:
> Then just define two server blocks. One redirects to 443 and the other
> to 8443.
I didn't realize that you could have multiple server blocks that were listening to the same port. That was the piece I was missing!
> Alternatively you could use map and a single server block. At the http
> level.
>
> map $host $redirect_port {
> hostnames;
> default 443;
> f.domain.com 8443; # this is the domain that redirects to 8443
> }
>
> server {
> server_name a.domain.com c.domain.com d.domain.com f.domain.com; # list all domains
> listen 80;
> return 301 https://$host:$redirect_port$request_uri;
> }
Ahh, that's very cool, too. Now I have two solutions for just the one problem.
Thanks!
--
Brad Knowles <brad at shub-internet.org>
LinkedIn Profile: <http://tinyurl.com/y8kpxu>
More information about the nginx
mailing list