Score:0

Redirect port 443 to 8080?

us flag

(note: I intentionally wrote "httpz" instead of "https" because I got an error message when trying to post the question)

I have a web server (docker container) running on 8080. I want people going to httpz://mydomain.com to access it. I changed the port configuration for the container (docker compose) to map 443 to 8080, and that works. But I would rather route traffic going to my server from port 443 to 8080. That way, I could start the docker container without root privileges.

How (specifically) do I configure the Ubuntu 20.40 server so that people accessing httpz://mydomain.com:443 gets routed to httpz://mydomain:8080?

I tried this command (taken from a guide I found online, but changed port 80 to 443):

sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8080

But it doesn't work. Traffic to 443 is not routed to 8080.

Nikita Kipriyanov avatar
za flag
Are you sure the service on port 8080 really is HTTPS and not plain HTTP?
djdomi avatar
za flag
I think you Want to use a reverse proxy instead of iptables
birgersp avatar
us flag
@NikitaKipriyanov Yes, the service on port 8080 is really HTTPS. As mentioned, if I configure docker to route 443 to 8080 it works.
birgersp avatar
us flag
@djdomi yes, maybe. Whatever is least hassle to configure, and easy to remove (restore) is fine.
Nikita Kipriyanov avatar
za flag
Then the most correct way to do this is to set up ports in docker. Docker has [instructions](https://docs.docker.com/engine/security/rootless/#exposing-privileged-ports) how to do this under unprivileged user.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.