frp配置https内网穿透测试环境

微信支付需要提供回调接口,要求是公网的,https的,通常可使用 ngrok 解决,但此文讲述如何使用frp 搭建https的内网穿透。

方法是 使用frp搭建服务端与客户端的http连接,然后使用nginx配置域名的https,然后转发到frp的http上。

frp配置

服务端
[common]
# 服务器端监听客户端连接请求的端口
bind_port = 7100

# http端口
vhost_http_port = 7200

# 身份验证
token = akjdlakjdkasd
客户端
[common]
# 你的服务器ip
server_addr = 121.141.139.147
# 跟frps的配置端口一致
server_port = 7100
#同服务端的配置token一致,用于验证
token = hahahaha


[my_http]
type = http
local_ip = 127.0.0.1
# 本地起的服务端口
local_port = 7200
custom_domains = hahaha.qq.tech
remote_port = 7200

Nginx配置

# frp 内网穿透
server {
    listen 443 ssl http2;
    #你的域名
    server_name hahaha.qq.tech;
    ssl on;
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_ciphers PROFILE=SYSTEM;
    ssl_prefer_server_ciphers on;
    #ssl证书的pem文件路径
    ssl_certificate  /home/cert/hahaha.qq.tech.pem;
    #ssl证书的key文件路径
    ssl_certificate_key /home/cert/hahaha.qq.tech.key;
    location / {
        # 转发到服务端的frp 监听的http端口
        proxy_pass  http://127.0.0.1:7200;
        # 必须要header,不然frp可能识别不了
        proxy_set_header   Host             $host;
	    proxy_set_header   X-Real-IP        $remote_addr;
	    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
}

访问: https://hahah.qq.tech/api/xxxx 时,就会转发到本地内网机器的server服务上

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值