Centos – How to make httpd accessible only through the VPN

centoshttpdnetworkingpptpvpn

I have a server running PPTP that is supposed to run an httpd (nginx) accessible only through the VPN. I'm also running a few other httpds too, which are not supposed to work on the VPN.

routing table

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         x.x.x.x         0.0.0.0         UG    0      0        0 bond0
x.x.x.x         x.x.x.x         255.255.255.255 UGH   0      0        0 bond0
x.x.x.x         0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
x.x.x.x         0.0.0.0         255.255.255.248 U     0      0        0 bond0
x.x.x.x         0.0.0.0         255.255.0.0     U     1008   0        0 bond0

when I ping mydomain.com (that should work with VPN)

ping mydomain.com
PING mydomain.com (x.x.x.x) 56(84) bytes of data.
^C
--- mydomain.com ping statistics ---
32 packets transmitted, 0 received, 100% packet loss, time 31248ms

but I can see the packets in tcpdump -vv -i ppp0

15:21:09.543764 IP (tos 0x0, ttl 52, id 37313, offset 0, flags [DF], proto ICMP (1), length 84)
    cable-x.x.x.x.dynamic.provider.com > anon-60-160.vpn.ipredator.se: ICMP echo request, id 4652, seq 8, length 64

Best Answer

You could probably configure that particular nginx instance to only listen on the PPTP interface.

The documentation for the http_core module specifies a listen directive to allow nginx to only listen on a certain address and/or port.

listen <IP of VPN>:<port> on the instance of nginx that should work on the vpn should be ok

Related Topic