http -> https redirection, with a twist?

Brad Knowles brad at
Wed Feb 29 02:07:19 UTC 2012


I've been trying to figure out how to set this up, I've gone through as much of the web site and wiki as I can, and I've searched on the net as much as I can.  I'm still stumped.

We have several different servers that we want to redirect from port 80, and most of them will land on the same machine but on port 443.  However, one of those needs to land on a different port -- 8443.

If this were a simple redirect without a twist, I'd probably go with something like the example shown at <>, although because I'm doing a one-to-one mapping of multiple FQDNs, and not just mapping a bunch of FQDNs to a single name, I'd be inclined to use an example more like this:

server {
  server_name;    # you can serve any number of redirects from here...
  listen 80;
  rewrite ^ https://$host$1$uri$is_arg$args permanent;

But with the single server definition listening to port 80 on all interfaces, I don't see how to make that one FQDN get redirected to port 8443 instead of port 443.

Am I missing something obvious here?

Brad Knowles <brad at>
LinkedIn Profile: <>

More information about the nginx mailing list