首页 > 解决方案 > 在 Guacamole RDP 会话中获取客户端主机名

问题描述

我们使用 Guacamole 进行 RDP 会话,但因为我们在城市周围有几个工作站。每次用户连接时,它都会返回:

ClientAddress: 10.0.0.1XX (Guacamole Server IP)
ClientName: Guacamole RDP

我需要知道每个连接是否有办法为我提供通过 Guac 连接的工作站的 IP 和真实名称。

Ex而不是10.0.0.190我需要192.168.1.XX的 ClientName TAG10(每个工作站都有自己的主机名。)

谢谢!

标签: guacamole

解决方案


对于 guacamole 1.0.0 及以上版本,您需要RemoteIpValve在您的 tomcat 中进行配置才能看到源 IP。

首先,确保您的代理发送X-Forwarded-For标头。例如(在 nginx 中):

location /guacamole/ {
    proxy_pass http://HOSTNAME: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;
    access_log off;
}

接下来,RemoteIpValve在tomcat中进行配置。它用于将远程 IP 地址传递给应用程序。

转到 tomcatconf目录,并编辑此文件 ( conf/server.xml)。在该<Host>部分下,添加以下内容:

<Valve className="org.apache.catalina.valves.RemoteIpValve"
               internalProxies="127.0.0.1"
               remoteIpHeader="x-forwarded-for"
               remoteIpProxiesHeader="x-forwarded-by"
               protocolHeader="x-forwarded-proto" />

有关更多信息,您可以参考这里: 鳄梨酱 - 数据库中的主机名日志记录


推荐阅读