ssl访问
# 配置和生成 HTTPS 证书来访问 FRP 需要以下几个步骤:
- 生成或获取 HTTPS 证书
- 配置 FRP 服务端以使用 HTTPS
- 配置客户端和服务器
# 1. 生成或获取 HTTPS 证书
你可以使用 Let's Encrypt 免费生成 HTTPS 证书,或者使用其他证书颁发机构(CA)提供的证书。以下是使用 Let's Encrypt 和 Certbot 生成证书的步骤:
# 使用 Certbot 生成证书
安装 Certbot:
yum install epel-release yum install certbot
1
2生成证书:
certbot certonly --standalone -d yourdomain.com
1请将
yourdomain.com
替换为你的实际域名。Certbot 会生成证书文件,通常存放在/etc/letsencrypt/live/yourdomain.com/
目录下。
# 2. 配置 FRP 服务端以使用 HTTPS
编辑 frps.ini
文件,添加 HTTPS 配置:
[common]
bind_port = 7000
vhost_http_port = 7071
vhost_https_port = 7443 # 添加 HTTPS 端口
# Dashboard 配置
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = admin
# HTTPS 证书配置
vhost_https_port = 443
subdomain_host = yourdomain.com
tls_cert_file = /etc/letsencrypt/live/yourdomain.com/fullchain.pem
tls_key_file = /etc/letsencrypt/live/yourdomain.com/privkey.pem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 3. 配置客户端和服务器
# 客户端 frpc.ini
文件
确保客户端配置文件 frpc.ini
正确配置:
[common]
server_addr = yourdomain.com
server_port = 7000
[http]
type = http
local_port = 8080
custom_domains = yourdomain.com
[https]
type = https
local_port = 8443
custom_domains = yourdomain.com
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
# 启动 FRP 服务端
重启 FRP 服务端以应用新的配置:
systemctl restart frp
1
# 验证 HTTPS 访问
确保你的域名指向你的服务器,并且防火墙允许 HTTPS 端口(通常是 443):
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload
1
2
2
现在,你应该能够通过 HTTPS 访问你的 FRP 服务。
# 总结
通过以上步骤,你已经成功生成了 HTTPS 证书,并配置了 FRP 服务端以使用 HTTPS。确保你的域名正确解析到你的服务器,并且防火墙配置正确。这样,你就可以通过 HTTPS 安全地访问你的 FRP 服务了。如果有任何问题或需要进一步的帮助,请随时提问。
在线编辑 (opens new window)
上次更新: 2025/02/25, 18:30:54