我有一个使用 docker-compose 和 nginx 设置的 L2TP 服务器,用于将某些主机过滤为主机名,但是当我尝试连接时,nginx 正在读取原始 IP,而不是通过 VPN 代理的 IP。
Nginx 显示x.x.x.x
而不是192.168.x.x
IP。
结果,403 (forbidden)
当我尝试连接任何不是我允许的远程 IP 时,它给了我一个错误,即使连接到 VPN,即使 VPN 给了我这样的 IP192.168.43.12
当我尝试network_mode: host
使用 VPN 时,它根本无法路由任何网络流量。
码头工人-compose.yml:
services:
vpn:
image: hwdsl2/ipsec-vpn-server
restart: always
env_file:
- ../config/vpn/vpn.env
ports:
- "500:500/udp"
- "4500:4500/udp"
- "1701:1701/udp"
privileged: true
hostname: example.com
volumes:
- /lib/modules:/lib/modules:ro
nginx:
build: ../config/nginx
restart: unless-stopped
ports:
- "80:80"
network_mode: host
nginx站点配置:
server {
listen *:80;
server_name bt.example.com;
index index.html;
access_log /dev/stdout upstreamlog;
error_log /dev/stderr debug;
location / {
allow 127.0.0.1;
allow 192.168.0.0/16;
#allow x.x.x.x; # one remote IP I want to allow, normally uncommented
deny all;
proxy_pass http://localhost:9091;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}