I've got a Rails application running on port 3000 (or any port I want for that matter) and I can access it by browsing to the public ip like so: 1.2.3.4:3000
but I would like to reach the same page by simply omitting the port number, since my domain registrar only allows the public ip, and no port number. Is there a setting somewhere to direct all incoming traffic from the site to a specific port?
Asked
Active
Viewed 951 times
0

Csteele5
- 1,262
- 1
- 18
- 36
2 Answers
4
There are a number of ways to do this:
-
I was unaware there was an actual command to do this. The one that worked for me was `sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000` – Csteele5 Nov 01 '15 at 17:49
-
1Be aware that you will need to reapply this rule after a reboot. For ways to do that, see http://stackoverflow.com/questions/9330694/how-to-permanently-update-iptables. – jarmod Nov 01 '15 at 18:19
2
If the url is http and your rails app uses port 80, then you don't have to specify port in the url.
If your url is https and your rails app uses port 443, then you don't have to specify port in the url.
If it is not a problem to use any of these two ports, then you can try it.

phoenix
- 3,069
- 3
- 22
- 29