currently my go server is running on port 4001 for https request. to access web application i need to type domainname:4001 in browser.
I would like only to type domainname ato make the connection to web server on port 40001.
currently my go server is running on port 4001 for https request. to access web application i need to type domainname:4001 in browser.
I would like only to type domainname ato make the connection to web server on port 40001.
You may either use iptables
or modify your program to listen on :80 (HTTP) or :443 (HTTPS).
With iptables, these commands will redirect all :80 and :443 traffic on your server to :8080 and :8443 respectively, internally.
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443
You may need to install iptables
. Run sudo apt install iptables
.
This is a temporal fix. To make it permanent, put those lines in your ~/.bashrc
If you don't want to use iptables
, then modify the ports your program is listening on. However, remember that ports under 1024 need root permissions, so you'll need to run the program as root.