使用带有docker的L2TP VPN更改远程IP wieh

时间:2018-06-10 07:41:47

标签: docker nginx docker-compose vpn l2tp

我有一个L2TP服务器设置了docker-compose,而nginx将某些主机设置为主机名,但是当我尝试连接时,nginx正在读取原始IP,而不是通过VPN代理的IP。

Nginx为IP显示x.x.x.x而不是192.168.x.x

因此,当我尝试连接任何不允许的远程IP时,它会给我403 (forbidden)错误,即使连接到VPN,甚至是当VPN给我一个像192.168.43.12

这样的IP时

当我在VPN上尝试network_mode: host时,它根本无法路由任何网络流量。

搬运工-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 site conf:

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;
    }

}

0 个答案:

没有答案