[GH-ISSUE #227] IP问题 #210

Closed
opened 2026-03-02 07:44:47 +03:00 by kerem · 0 comments
Owner

Originally created by @BennyTian on GitHub (Feb 8, 2021).
Original GitHub issue: https://github.com/hwdsl2/docker-ipsec-vpn-server/issues/227

我再一台服务器上安装了 VPN, IP 假设是 A .

当我连接上VPN之后去访问我的内部系统,但获取到的IP却是 客户端的真实IP, 不是VPN的IP,

nginx配置:

proxy_set_header RealIP $remote_addr;
proxy_set_header Host $proxy_host;
proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP  $remote_addr;
proxy_set_header X-Forwarded-Scheme  $scheme; 

vpn docker启动脚本:

#!/bin/sh

NAME=vpn-server

docker stop $NAME
docker rm $NAME

docker run \
    --name ${NAME} \
    --env-file ./vpn.conf \
    --restart=always \
    -v /nfs/vpn/database/:/etc/ipsec.d \
    -p 500:500/udp \
    -p 4500:4500/udp \
    -d --privileged \
    hwdsl2/ipsec-vpn-server

vpn.conf

# Note: All the variables to this image are optional.
# See README for more information.
# Define your own values for these variables
# - DO NOT put "" or '' around values, or add space around =
# - DO NOT use these special characters within values: \ " '
VPN_IPSEC_PSK=yyy
VPN_USER=yyy
VPN_PASSWORD=yyy

# Enable IKEv2. See: https://git.io/ikev2docker
VPN_SETUP_IKEV2=no

# Define additional VPN users
# - Uncomment and replace with your own values
# - DO NOT put "" or '' around values, or add space around =
# - Usernames and passwords must be separated by spaces
VPN_ADDL_USERS=xxx
VPN_ADDL_PASSWORDS=xxx

# Use alternative DNS servers
# - Uncomment and replace with your own values
# - By default, clients are set to use Google Public DNS
# - Example below shows Cloudflare's DNS service
# VPN_DNS_SRV1=1.1.1.1
# VPN_DNS_SRV2=1.0.0.1

感谢

Originally created by @BennyTian on GitHub (Feb 8, 2021). Original GitHub issue: https://github.com/hwdsl2/docker-ipsec-vpn-server/issues/227 我再一台服务器上安装了 VPN, IP 假设是 A . 当我连接上VPN之后去访问我的内部系统,但获取到的IP却是 客户端的真实IP, 不是VPN的IP, nginx配置: ``` proxy_set_header RealIP $remote_addr; proxy_set_header Host $proxy_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Scheme $scheme; ``` vpn docker启动脚本: ``` #!/bin/sh NAME=vpn-server docker stop $NAME docker rm $NAME docker run \ --name ${NAME} \ --env-file ./vpn.conf \ --restart=always \ -v /nfs/vpn/database/:/etc/ipsec.d \ -p 500:500/udp \ -p 4500:4500/udp \ -d --privileged \ hwdsl2/ipsec-vpn-server ``` vpn.conf ``` # Note: All the variables to this image are optional. # See README for more information. # Define your own values for these variables # - DO NOT put "" or '' around values, or add space around = # - DO NOT use these special characters within values: \ " ' VPN_IPSEC_PSK=yyy VPN_USER=yyy VPN_PASSWORD=yyy # Enable IKEv2. See: https://git.io/ikev2docker VPN_SETUP_IKEV2=no # Define additional VPN users # - Uncomment and replace with your own values # - DO NOT put "" or '' around values, or add space around = # - Usernames and passwords must be separated by spaces VPN_ADDL_USERS=xxx VPN_ADDL_PASSWORDS=xxx # Use alternative DNS servers # - Uncomment and replace with your own values # - By default, clients are set to use Google Public DNS # - Example below shows Cloudflare's DNS service # VPN_DNS_SRV1=1.1.1.1 # VPN_DNS_SRV2=1.0.0.1 ``` 感谢
kerem closed this issue 2026-03-02 07:44:47 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/docker-ipsec-vpn-server#210
No description provided.