1

I try to figure out how to point a.b.c.d:3000 to my domain name. Here, a.b.c.d is my IP address.

As per this post:

How to use DNS/Hostnames or Other ways to resolve to a specific IP:Port

I get the impression that I need to set Webrick to host on port 80, since that is the default assumed port, hence I can map a.b.c.d to my domain name and mydomain.org will reach my site.

Is this a correct assumption or am I going about this the wrong way?

Anyway, I can't get Webrick to use port 80, I get the following error:

WARN TCPServer Error: Permission denied - bind(2)

Checking for listeners on port 80:

$ netstat -tlnp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:8089          0.0.0.0:*               LISTEN      3266/banshee    
tcp6       0      0 ::1:631                 :::*                    LISTEN      -               

No other processes using port 80.

From other posts, I get the impression that mapping to ports below 1024 is not possible.

Running the following command:

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

Now, setting Webrick on port 8080, I still can't reach my site from a.b.c.d! (nor a.b.c.d:80)

This situation shouldn't be such an uncommon one, what am I missing? If it matters, I use the standard Rails 4 development environment of Webrick, because I only expect like 100 page views/months.

Kappie001
  • 111
  • 1
  • 2
  • You'll get more traffic than that every day just from Googlebot. Best to do it right the first time. Apache+Passenger, nginx+unicorn, etc. – Michael Hampton Nov 24 '13 at 19:25

2 Answers2

1

Normal users (uid != 0) cannot bind ports <1024 on UNIX-like systems. You could do some iptables hacks or run Werbick as root (or other means described here) instead, but I would not suggest to do so.

Take a proper webserver like Apache, nginx or lighttpd and let it proxy all the traffic to your Webrick. That should be like 5 lines of configuration and you will end up with a setup that you can control and modify way better.

zhenech
  • 1,492
  • 9
  • 13
0

try running on different port, like run as non-root user on tcp/8080

also, run lsof |egrep "80|http", to see what's running on tcp/80

it may just be webrick is broken... try mod_passenger if that's a rails app

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
nandoP
  • 2,001
  • 14
  • 15