Redirect http:8080 to https:8443

Jim Ohlstein jim at mailman-hosting.com
Mon Jun 5 12:43:17 UTC 2017


On Mon, 2017-06-05 at 15:28 +0300, ST wrote:
> Hello,
> 
> I try to redirect http on port 8080 to https on port 8443 as follows,
> but it doesn't seem to work. http redirects to https, but the port
> remains the same - 8080. Why?
> 
> Thank you!
> 
> # redirect http to https
> server {
>     listen 8080;
>     server_name n.example.com;
>     return 301 https://$host:8443/$request_uri;
> }
> 
> server {
>         listen   8443 ssl;
> 	server_name n.example.com;
> ...
> }

This is _just a guess_, but "$host" may contain the port.

Try using:

	return 301 https://n.example.com:8443$request_uri;

-- 
Jim Ohlstein
Professional Mailman Hosting
https://mailman-hosting.com/



More information about the nginx mailing list