Redirect port 443 to 8123 with iptables? (or similar)

I’m currently using Hassbian, and I can’t forward port 443 to 8123 with my router (Sky Hub), but I found a way of doing it through Terminal (on this forum).

With these commands it does what I need

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

sudo apt-get install iptables-persistent

Is there any way to do this with Hass.io, so my DuckDNS URL could be https://my-url.duckdns.org instead of https://my-url.duckdns.org:8123?
1 Like

Does your router just restrict port 443 from being re-directed, or does it not allow any port re-direction?

I can open ports with my router (I open port 443), but as far as I’m aware it can’t forward one port to another (443 to 8123).

Most routers allow you to set up rules for port forwarding. I’m not sure if this matches your router, but it looks like it is possible, just more confusing than most routers.

http://helpforum.sky.com/t5/Broadband/How-To-Tutorial-Port-Forwarding-Open-Nat-for-Sky-SR101-or-SR102-Gamers-have-a-look/td-p/2440407

I chose to use a different port than 443 so that I would be less likely to show up if someone is scanning standard ports. It is still using ssl and works with any browser as well as the iOS app.

I thought if you set ‘Start Port’ and ‘Finish Port’ it opened all ports e.g. opened all ports from 433 to 8123 :sweat_smile:

If that’s not the case and it forwards 433 to 8123 then that’s excellent, it already does what I need to do :slightly_smiling_face:

…I’ve looked into this with my router and it doesn’t support port mapping, so ‘Start Port’ and ‘Finish Port’ just sets the range of ports to open.

So it’s not possible to forward the external port 433 to the internal port 8123 somehow within Hass.io?

Can you reflash your router with something like advanced tomato? Gives you a lot of options. Can even ssh to it and set it up to do all kinds of fun things. I have used mine as an audio server with a usb card.

Not sure if you have the same router, but here’s a video on how to setup port forwarding on a Sky Hub router.

Isn’t it possible to change the server_port parameter of the http component with hassio? If there’s no other service internally that has to strictly use 443 and the router just doesn’t support proper NAT, then switching the port in hassio seems like an easy workaround.

Install the nginx add-on. It will do the forwarding as well as handle ssl.

1 Like

Not sure. I might look into that in the future. Thanks


[quote="Kazakaz, post:8, topic:40217, full:true"] Not sure if you have the same router, but here's a video on how to setup port forwarding on a Sky Hub router. [/quote]

It’s port mapping I’m wanting to do (redirecting a specific external port to a different internal port), not port forwarding (just open some ports) :slightly_smiling_face:


[quote="danielperna84, post:9, topic:40217, full:true"] Isn't it possible to change the `server_port` parameter of the [http](https://home-assistant.io/components/http/) component with hassio? If there's no other service internally that has to strictly use 443 and the router just doesn't support proper NAT, then switching the port in hassio seems like an easy workaround. [/quote]

Yes, I could do this. I might have to end up doing that if I don’t find a better solution.
The reason I want to avoid this if possible is I have quite a few Google Assistant → webhook applets setup in IFTTT, and I’d have to go through them all and add the port number to my URLs. Not terrible, but I’d like to avoid that if possible.


[quote="NotoriousBDG, post:10, topic:40217, full:true"] Install the nginx add-on. It will do the forwarding as well as handle ssl. [/quote]

I’ll look into that, thanks!

I used this on my setup and it works thanks for that. However it seems to have screwed up my samba server, any suggestions?

Try re-installing samba, and edit/check your ‘smb.conf’ file to make sure everything’s OK?

Thanks for the reply, I completely purged it and ran hassbian-config samba script and its now working again.

Thanks again