frp是内网穿透利器,解决了想要在公司访问家里内网NAS,或是在家里访问公司服务问题。一般配置见https://vhsal.com/frp-config/ 。但是现在很多服务都需要ssl证书,或者为了安全的考虑要对内网的网站使用证书访问,就需要对frp进行进一步的配置了。
配置逻辑为网站保持不变,仍然不使用证书。加密解密过程由frpc完成。

服务器端frps配置

修改frps.ini

[common]
bind_port = 7000
token=XXXXXX
#新增配置
vhost_https_port = 9443 端口为映射的端口

内网frpc配置

修改frpc.ini配置根据自己情况修改,证书配置"plugin_crt_path"、"plugin_key_path"使用的是对应域名的nginx的证书。"plugin_local_addr"就是内网对应的http响应端口

[common]
server_addr = 服务器IP
bind_port = 7000
token=xxxxxx
[test_htts2http]
type = https
custom_domains = 域名
plugin = https2http
plugin_local_addr = 127.0.0.1:8000
# HTTPS 证书相关的配置
plugin_crt_path = ./ssl/server.crt
plugin_key_path = ./ssl/server.key
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

证书

ssl证书现在有很多免费的证书提供,笔者使用的是Lets Encrypt证书,申请和续期见https://www.hefuni.com/lets_encrypt_free_ssl/ 。Lets Encrypt证书证书,保存在 /etc/letsencrypt/archive/xxx.com/下