FRP + nginx 获取客户端真实IP

本文详细解释了如何在frpc.toml中配置网站代理,包括api.test.com的HTTPS代理设置,以及nginx中的相关SSL配置,如SSL证书、协议版本、加密算法等。还涉及了错误页面处理和URL重写规则。

frpc.toml 中网站代理配置:


[[proxies]]
name = "api.test.com"
type = "https"
localIP = "192.168.123.180"
localPort = 443
compression = true
subDomain = "api"
transport.proxyProtocolVersion='v1'

nginx中api.test.com的配置:

server
{
    listen 80; 
    listen 443 ssl http2 proxy_protocol;

	set_real_ip_from 192.168.123.180;  # FRP 服务器的 IP 地址
    real_ip_header proxy_protocol;

    server_name api.test.com;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/api.test.com/public;


    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    #HTTP_TO_HTTPS_START
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    #HTTP_TO_HTTPS_END
    ssl_certificate    /www/server/panel/vhost/cert/api.test.com/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/api.test.com/privkey.pem;
    ssl_protoco
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

risingsun529

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值