我在nginx中使用下面的配置来代理RDP连接:
server { listen 80; server_name domain.com; location / { proxy_pass http://192.168.0.100:3389; } }
server {
listen 80;
server_name domain.com;
location / {
proxy_pass http://192.168.0.100:3389;
}
字符串但连接不通过。我的猜测是,问题是proxy_pass中的http。谷歌搜索“Nginx RDP”没有产生太多。有人知道这是否可能吗?如果可能,又是如何做到的呢?
proxy_pass
http
vbopmzt11#
好吧,实际上你是对的,http是问题所在,但不完全是你代码块中的问题。让我们解释一下:在你的nginx.conf文件中,你有类似的东西:
nginx.conf
http { ... ... ... include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*;}
http {
...
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
字符串所以你在conf文件中写的所有东西都在这个http块/作用域中。但是rdp不是http是一个不同的协议。我所知道的nginx处理这个问题的唯一解决方法是在tcp级别上工作。所以在nginx.conf内部和http外部,你必须像这样声明stream块:
tcp
stream
stream { # ... server { listen 80; proxy_pass 192.168.0.100:3389; }}
stream {
# ...
proxy_pass 192.168.0.100:3389;
型使用上面的配置只是在tcp层上复制你的后端,当然这是有代价的。你可能注意到它缺少server_name属性,你不能在stream范围内使用它,而且你失去了http级别上的所有日志记录功能。有关此主题的更多信息,请查看docs
server_name
hfwmuf9z2#
对于任何希望使用Nginx负载平衡RDP连接的人来说,这是我所做的:像往常一样配置nginx,将HTTP(S)流量重新路由到所需的服务器。在该服务器上,安装myrtille(它需要IIS和.Net 4.5),然后您就可以从浏览器将RDP导入您的服务器!
yvt65v4c3#
如果你正在寻找一个完整的配置,不包含一堆点**,永远不会通过nginx配置测试**,下面是一个完整的和测试的配置。此示例侦听端口25301并将连接转发到rds.example.com:25301。然后在无线路由器中,您必须将端口25301上的传入连接转发到目标Windows PC IP地址和端口3389。
25301
rds.example.com:25301
3389
| 服务名称|外部端口|内部端口|内部IP地址|议定书|| --|--|--|--|--|| 服务器9_RDP| 25301 | 3389 |10.0.0.9|两|
stream { tcp_nodelay on; resolver 1.1.1.1 1.0.0.1 valid=60s; resolver_timeout 5s; server { listen 25301; # proxy_pass 192.168.0.1:25301; proxy_pass rds.example.com:25301; proxy_connect_timeout 10s; proxy_timeout 2h; # Preserve client IP address proxy_bind $remote_addr transparent; allow 192.168.1.0/24; # Example for allowing specific IPs deny all; # Logging access_log off; error_log /var/log/nginx/error.log warn; }}
tcp_nodelay on;
resolver 1.1.1.1 1.0.0.1 valid=60s;
resolver_timeout 5s;
listen 25301;
# proxy_pass 192.168.0.1:25301;
proxy_pass rds.example.com:25301;
proxy_connect_timeout 10s;
proxy_timeout 2h;
# Preserve client IP address
proxy_bind $remote_addr transparent;
allow 192.168.1.0/24; # Example for allowing specific IPs
deny all;
# Logging
access_log off;
error_log /var/log/nginx/error.log warn;
字符串
3条答案
按热度按时间vbopmzt11#
好吧,实际上你是对的,
http
是问题所在,但不完全是你代码块中的问题。让我们解释一下:在你的
nginx.conf
文件中,你有类似的东西:字符串
所以你在conf文件中写的所有东西都在这个
http
块/作用域中。但是rdp不是http是一个不同的协议。我所知道的nginx处理这个问题的唯一解决方法是在
tcp
级别上工作。所以在
nginx.conf
内部和http
外部,你必须像这样声明stream
块:型
使用上面的配置只是在tcp层上复制你的后端,当然这是有代价的。你可能注意到它缺少
server_name
属性,你不能在stream
范围内使用它,而且你失去了http
级别上的所有日志记录功能。有关此主题的更多信息,请查看docs
hfwmuf9z2#
对于任何希望使用Nginx负载平衡RDP连接的人来说,这是我所做的:
像往常一样配置nginx,将HTTP(S)流量重新路由到所需的服务器。
在该服务器上,安装myrtille(它需要IIS和.Net 4.5),然后您就可以从浏览器将RDP导入您的服务器!
yvt65v4c3#
如果你正在寻找一个完整的配置,不包含一堆点**,永远不会通过nginx配置测试**,下面是一个完整的和测试的配置。
此示例侦听端口
25301
并将连接转发到rds.example.com:25301
。然后在无线路由器中,您必须将端口25301
上的传入连接转发到目标Windows PC IP地址和端口3389
。端口转发-路由器设置
| 服务名称|外部端口|内部端口|内部IP地址|议定书|
| --|--|--|--|--|
| 服务器9_RDP| 25301 | 3389 |10.0.0.9|两|
NGINX - RDP配置
字符串