Setup: one internet router 3 with a VPN server. Local IP 192.168.1.x
2 web servers : one 192.168.1.19 with ports 80 and 443 redirected to it, and a backup server 192.168.1.20 with no ports redirected.
Access from another location local IP 192.168.2.x through VPN tunnel
both server have a small file (ip.php) that prints the received IP adresses:
Access to 1st server: https://192.168.1.19/ip.php
response:
REMOTE_ADDR=178.198.59.147. <— this is the public address of the router
SERVER_ADDR=192.168.1.19
HTTP_HOST=192.168.1.19
HTTP_X_REAL_PORT=62951
HTTP_X_PORT=443
HTTP_X_HTTPS=on
HTTP_X_REAL_IP=178.198.59.147
HTTP_X_FORWARDED_BY=192.168.1.19
access 2nd server: https://192.168.1.20/ip.php
response:
REMOTE_ADDR=192.168.1.219 <– this is the IP of the VPN tunnel
SERVER_ADDR=192.168.1.20
HTTP_HOST=192.168.1.20
HTTP_X_REAL_PORT=62938
HTTP_X_PORT=443
HTTP_X_HTTPS=on
HTTP_X_REAL_IP=192.168.1.219
HTTP_X_FORWARDED_BY=192.168.1.20
My question: why are these 2 accesses different in term of REMOTE_ADDR ?
The server that has ports redirected is presented the public IP, the server without redirections is presented local VPN IP
My problem: these servers reject by design (it is my choice) for some pages all addresses that are non local IP written in the form 192.168.1.xx
The second server 1.20 is OK, the first server 1.19 rejects the page because the presented IP is a public address
If I delete the port redirections 80 AND 443, the first server replies with the VPN local address. If I again reprogram the redirections the server responds with the public IP. Why this behavior ??
« Is there a setting to disable NAT loopback / source NAT for VPN clients, so that hosts with port forwarding see the VPN client’s local address? »