Nginx反代FRP,共用80端口
in Linux with 0 comment
Nginx反代FRP,共用80端口
in Linux with 0 comment

需求:目前在服务器上的Nginx运行了一个网站,同时家里使用了FRP内网穿透以达到能访问内网中的网站,Nginx占用了80和443端口,FRP使用了非80和443端口,需要将FRP访问和Nginx访问都使用80和443端口。

Nginx端配置

server {
    listen 80;
    server_name dl.htlac.com;
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header    Host            $host:80;
        proxy_set_header    X-Real-IP       $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_hide_header   X-Powered-By;
    }
}

将Nginx反代8080端口(FRP服务器端侦听的vhost端口)


Frp服务端配置

[common]
bind_port = 8787
vhost_http_port = 8080
token = passwd
max_pool_count = 100

Frp客户端配置

[common]
server_addr = Server_IP 
server_port = 8787 
token = passwd
login_fail_exit = false 

[xxx]
type = http
local_port = 80
subdomain = dl.htlac.com

FRP每个版本配置都会有细微的变化,按照官方的格式要求配置即可。

如果需要代理SSL,则需要注意配置应当如下:


location /a-path/ {
    proxy_pass https://a-address/;
    proxy_set_header Host $proxy_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_ssl_session_reuse off;
    proxy_ssl_server_name on;
    proxy_ssl_name $proxy_host;
    proxy_ssl_protocols TLSv1.2;
The article has been posted for too long and comments have been automatically closed.