Install And Config Frp

项目地址

frps service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
docker build --pull --rm -f "Dockerfile/frps.Dockerfile" -t frps Dockerfile

mkdir -p /etc/frp
cat >/etc/frp/frps.ini<<EOF
[common]
bind_port = 37000
token =
# 打开 dashboard
dashboard_port = 7500
dashboard_user =
dashboard_pwd =

enable_prometheus = true

vhost_http_port = 8000
subdomain_host = xxx.com
tcp_mux = true
EOF

docker run -d --network host --name frps --restart=always -v /etc/frp:/frp frps

frpc service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
docker build --pull --rm -f "Dockerfile/frpc.Dockerfile" -t frpc Dockerfile

mkdir -p /etc/frp
cat >/etc/frp/frpc.ini<<EOF
[common]
token =
server_addr =
server_port = 37000
tcp_mux = true
admin_addr =
admin_port = 7400
admin_user =
admin_pwd =

[router]
type = http
local_ip =
local_port = 80
http_user =
http_pwd =
use_encryption = true
use_compression = true
subdomain = r
EOF

docker run -d --network host --name frpc --restart=always -v /etc/frp:/frp frpc

注意事项

  1. frp server 端打开了 web dashboard,nginx 统一反代页面后域名访问
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name frps.xxx.com;

    # SSL
    ssl_certificate xxx.cer;
    ssl_certificate_key xxx.key;

    location / {
    proxy_pass http://10.0.0.1:7500;
    proxy_redirect http://$host/ http://$http_host/;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    }
    }

    # HTTP redirect
    server {
    listen 80;
    listen [::]:80;

    server_name frps.xxx.com;

    location / {
    return 301 https://$host$request_uri;
    }
    }
  2. frp client 端打开 admin 后台,可以通过页面刷新配置
  3. 转发内网 http 服务,并启用 https,需要注意 server_name 和 fprc 配置中 $subdomain.$subdomain_host 一致,泛域名解析指向或者按需增加配置
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name r.xxx.com;

    # SSL
    ssl_certificate xxx.cer;
    ssl_certificate_key xxx.key;

    location / {
    proxy_pass http://10.0.0.1:8000;
    proxy_redirect http://$host/ http://$http_host/;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    }
    }

    # HTTP redirect
    server {
    listen 80;
    listen [::]:80;

    server_name r.xxx.com;

    location / {
    return 301 https://$host$request_uri;
    }
    }

Install And Config Frp

https://1.not.icu/install-frp/

作者

Sony Dog

发布于

2022-07-31

更新于

2023-12-26

许可协议

CC BY-NC-SA 4.0