Apache does not log internal ip when connected to vpn

chasank asked:

I’m having vps which has apache and openvpn at the same time. When I’m connecting vpn with my client computer, my public ip becomes vps’s public ip and server assigns an internal ip to my client according to configuration. When I access web server from the client using browser, I am expecting to see client’s internal ip or at least public ip which is the same with the server at access_log files, However apache logs router’s public ip. Is this behaviour normal or I am having some misconfiguration?

My answer:

That’s normal, because your web server and VPN server are on the same IP address.

In order to route the VPN tunnel traffic to your VPN in the first place, your client machine must create the tunnel between your machine and your VPN using your actual global IP address. Traffic for every other address can pass through the VPN but traffic for that IP address will pass outside the VPN tunnel. Otherwise it would not be possible to construct the tunnel.

Obviously your VPN server, like any other service, should not be co-hosted on the same (virtual) machine with anything else.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.