网站的服务器在家里,那必然是没有公网 IP 的,动态的也没有。不过我手里有个香港的 CN2 机子,于是就拿来穿出去。最开始是直接用 FRPS 直接监听服务端 7443 端口的,然后 NGINX SNI 分流转发给 FRPS,因为 VPS 上面还有其他两个站点。但是呢,会有一个问题,Stream 的四层代理会丢用户端的 IP,而 FRPS 又不支持接收 PROXY Protocol 数据,导致网站识别到的 IP 全是 127.0.0.1(当然这是 FRPC 打开 PROXY Protocol 后的,不然全是 FRPC 的当前内网 IP)。
全网搜索后,并没有找到解决办法。直线救国不行的话,那就只能曲线救国了,于是乎又在 VPS 上安装了 FRPC(对,同时安装了 FRPS 和 FRPC),然后让 FRPS 监听 443 端口,80 端口继续让 NGINX 监听(用于任意域名重定向 443),结果行了,网站都能正常识别用户端的 IP 了。
在这里分别留下配置做个备份。
FRPS:
[common]
bind_port = 7000
vhost_http_port = 8080
vhost_https_port = 443
token = password
dashboard_port = 7500
dashboard_user = user
dashboard_pwd = password
log_file = /var/log/frps.log
log_level = info
log_max_days = 3
FRPC(VPS & Local):
[common]
server_addr = 127.0.0.1
server_port = 7000
token = password
user = localhost
[https_1]
type = https
local_ip = 127.0.0.1
local_port = 8443
remote_port = 443
use_encryption = false
use_compression = false
custom_domains = example.com
proxy_protocol_version = v2
[https_2]
type = https
local_ip = 127.0.0.1
local_port = 8443
remote_port = 443
use_encryption = false
use_compression = false
custom_domains = www.example.com
proxy_protocol_version = v2
NGINX:
http {
server {
listen 80 default ipv6only=off;
return 301 https://$http_host$request_uri;
}
}
Comments | NOTHING