根据您提供的frps.toml和frpc.toml配置,我将详细说明如何通过Nginx反向代理,实现使用域名xx.xx访问Windows远程桌面的完整配置流程。
现有FRP配置分析
您提供的FRP配置显示:
- FRP服务端(frps)运行在公网服务器(x.x.x.x)的7000端口
- HTTP服务设置在7002端口
- FRP管理面板在7500端口
- 远程桌面连接被映射到服务端的7001端口
- 客户端本地RDP服务在3389端口
- 已启用数据加密和压缩传输
Nginx配置步骤
1. 在公网服务器上安装Nginx
1 2 3 4
| apt update apt install nginx -y
yum install nginx -y
|
2. 创建Nginx配置文件
创建文件 /etc/nginx/conf.d/rdp.conf
并添加以下内容:
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 31 32 33 34 35 36 37 38 39 40 41
| server { listen 80; server_name xxxx.com www.xxxx.com; return 301 https://$host$request_uri; }
server { listen 443 ssl; server_name xxxx.com www.xxxx.com; ssl_certificate /etc/nginx/ssl/xxxx.crt; ssl_certificate_key /etc/nginx/ssl/xxxx.key; ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; location /rdp/ { proxy_pass http://localhost:8080/guacamole/; proxy_buffering off; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_cookie_path /guacamole/ /rdp/; access_log off; } location /frp/ { proxy_pass http://localhost:7500/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; } }
|
3. 配置TCP流量转发
编辑Nginx主配置文件 /etc/nginx/nginx.conf
,在http部分外添加stream模块配置:
1 2 3 4 5 6 7 8 9 10
| stream { server { listen 3389; proxy_pass 127.0.0.1:7001; proxy_connect_timeout 10s; proxy_timeout 30s; } }
|
4. 申请并配置SSL证书
可以使用Let’s Encrypt免费证书:
1 2
| apt install certbot python3-certbot-nginx -y certbot --nginx -d xxxx.xx -d xxxx.xx
|
5. 配置域名DNS解析
在域名管理面板中,为xxxx.xx和www.xxxx.com添加A记录,指向您的服务器IP(x.x.x.x)。
6. 测试并重启Nginx
1 2
| nginx -t systemctl restart nginx
|
7. 防火墙配置
确保服务器防火墙开放必要端口:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| ufw allow 80/tcp ufw allow 443/tcp ufw allow 3389/tcp ufw allow 7000/tcp ufw allow 7001/tcp ufw allow 7002/tcp
firewall-cmd --permanent --add-port=80/tcp firewall-cmd --permanent --add-port=443/tcp firewall-cmd --permanent --add-port=3389/tcp firewall-cmd --permanent --add-port=7000-7002/tcp firewall-cmd --reload
|
远程桌面连接方式
方法一:直接使用RDP客户端
在远程桌面客户端中,可以直接使用域名连接:
- 地址:xxxx.xx
- 端口:3389(默认,可省略)
- 用户名、密码:Windows账户凭据
方法二:使用Web接口(如配置了Guacamole)
- 访问 https://xxxx.xx/rdp/
- 输入Windows的用户名和密码
- 通过Web浏览器访问远程桌面
安全建议
- 限制远程桌面访问IP:通过Nginx配置添加IP白名单
- 启用Windows网络级别身份验证
- 定期更新远程桌面服务补丁
- 配置失败登录尝试限制
- 使用复杂密码
- 考虑使用VPN作为额外安全层
这套配置实现了通过加密隧道将Windows远程桌面安全地暴露到互联网,并通过域名xxxx.xx提供访问,同时利用SSL加密保护数据传输安全。