Nginx – pass HTTPS traffic from one port to another

httpsnginxosxport-forwardingsslUbuntu

I'm doing a proxy_pass in on port 80 to 8000 on my remote server, and then a port forward from 8000 to 80 from the remote to my localhost. This works great, but I'd also like to do it with but it seems like needs a valid cert to pass the traffic on.

Is there a way for my remote server to simply forward the trafic from port 443 to say 8443 (and then I'll forward remote 8443 to local 443). Then terminate on my development machine instead instead of needing to do it on the remote server?

My remote runs and my localhost runs .

Best Answer

While nginx probably has a third-party module to deal with raw TCP connections, I'm pretty sure that by default everything has to be either HTTP or terminated HTTPS. I think in your situation I'd do port forwarding at the network level:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443