Greetings all,
Sometimes you prefer that your applications can be reached without adding the extra port indication. Like http://yourserver/yourapplication/ instead of http://yourserver:8080/yourapplication/. But since the default http-port is 80 and only root (on most Linux systems) can run a service on a port below 1000, you seem to be stuck. Not so. Our trusted iptables comes to the rescue once more. We keep our NetKernel frontend running at port 8080 ... and route the requests to port 80 there (bit like the mountain coming to Mozes ... or was that the other way around ?).
Step 1 - Free port 80
Those webhosting-services today are really good. I remember when you had to pay for a - very restricted - Unix shell account. These days you get root on your own host that has Apache and if you are lucky MySQL running already.
Nice, but that Apache is bound to be running - as root - on port 80. Check if your host has a httpd process running and if it does, stop it :
That will take care of that ...
Step 2 - Revised iptables script
What has changed ?
1) Port 80 was added to the ''allowed ports''
2) A PREROUTING rule was added for a NAT translation from port 80 to port 8080.
Actually 1) and 2) do the trick ... however, since we like a secure host, there''s a 3)
3) A PREROUTING rule was added to DROP all external traffic going directly to port 8080.
We can''t just drop port 8080 from the allowed ports by the way, for the NAT rule would also not work in that case.
Step 3 Test the result
You should now be able to reach http://yourserver/yourapplication/
You should no longer be able (if you did 3) to reach http://yourserver:8080/yourapplication/
Enjoy,
Tom
P.S. Linux is like a Wigwam. It has no windows and an Apache inside ...
Sometimes you prefer that your applications can be reached without adding the extra port indication. Like http://yourserver/yourapplication/ instead of http://yourserver:8080/yourapplication/. But since the default http-port is 80 and only root (on most Linux systems) can run a service on a port below 1000, you seem to be stuck. Not so. Our trusted iptables comes to the rescue once more. We keep our NetKernel frontend running at port 8080 ... and route the requests to port 80 there (bit like the mountain coming to Mozes ... or was that the other way around ?).
Step 1 - Free port 80
Those webhosting-services today are really good. I remember when you had to pay for a - very restricted - Unix shell account. These days you get root on your own host that has Apache and if you are lucky MySQL running already.
Nice, but that Apache is bound to be running - as root - on port 80. Check if your host has a httpd process running and if it does, stop it :
chkconfig httpd off |
That will take care of that ...
Step 2 - Revised iptables script
SERVER_IP=<your fixed server ip> |
What has changed ?
1) Port 80 was added to the ''allowed ports''
2) A PREROUTING rule was added for a NAT translation from port 80 to port 8080.
Actually 1) and 2) do the trick ... however, since we like a secure host, there''s a 3)
3) A PREROUTING rule was added to DROP all external traffic going directly to port 8080.
We can''t just drop port 8080 from the allowed ports by the way, for the NAT rule would also not work in that case.
Step 3 Test the result
You should now be able to reach http://yourserver/yourapplication/
You should no longer be able (if you did 3) to reach http://yourserver:8080/yourapplication/
Enjoy,
Tom
P.S. Linux is like a Wigwam. It has no windows and an Apache inside ...