So I used iptables to redirect traffic from 80 to 8501 as follows:
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8501
However this doesn't work with https
. I was able to do the certbot
stuff successfully however my script only listens to :8501
. How can I make sure that the user doesn't have to type the extra example.com:8501
and that example.com
always shows contents from :8501? I have the following code that I was suggested but I'm not sure where to put this text:
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /(.*) ws://localhost:8501/$1 [P]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /(.*) http://localhost:8501/$1 [P]
ProxyPassReverse / http://localhost:8501
I've also tried changing to Listen 8501
in the ports.conf
file but everytime I do that and I try to restart it, it refuses to restart with the error:
Job for apache2.service failed because the control process exited with error code.
UPDATE: so I was able to redirect 8501 to 80 (conf can be seen in the images below) however it still shows the default Apache page when accessed through https :/