0

I have setup Debian server which IP is 192.168.1.86

Inside this debian server I have virtual CentOs server which IP is 192.168.1.87

I can access both from my local network from Windows PC. I have opened firewall so that my Debian computer has public ip which I can access 84.251.xxx.xxx Now is there a way to access my CentOs server through the public ip somehow? I am running apache2 on the debian.

I know it can be probably done via virtualhosts/mod proxy but is there easier way?

1 Answer 1

0

If you cannot do it in your router i'd try with NAT in the machines.

Do this in the Debian:

iptables -t nat -I OUTPUT  -d 84.251.xxx.xxx  -p tcp --dport 80  -j DNAT --to-destination 192.168.1.87

This will redirect public IP port 80 to CentOS' private IP. If you want to redirect all ports remove the --dport 80 part.

Note: I first thought of routes, but looks better to me.

3
  • Okay, but if I want to access both, my debian apache and centos? If I understood right this forwards everything to Centos. I have multiple websites running on debian server so I cant just forward everything to centos. I need both web servers.
    – Shnigi
    Commented Jun 27, 2014 at 7:42
  • If the same public IP needs to be shared on the same port there is not in a simple way (ie: not at layer 3). You need something application aware (like a proxy).
    – LatinSuD
    Commented Jun 27, 2014 at 8:49
  • Thats what I was thinking, so then my only option would be to get domain and forward traffic with mod proxy and virtual host: httpd.apache.org/docs/2.2/mod/mod_proxy.html But then I cant access my Centos just simply through IP, I always need domain. Tricky.
    – Shnigi
    Commented Jun 27, 2014 at 9:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .