By VSO SOFTWARE on Thursday, 31 July 2025
Posted in General
Replies 2
Likes 0
Views 16.5K
Votes 0
I'm using a Websocket server behind NGINX. Here is the part in the configuration file of nginx to achieve the result:


location /websocket/ {
proxy_pass http://localhost:8090;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 86400;
}


This is working very well, however I come across a problem for my usage: Nevertheless I am using X-Forwarded-For and X-Real-IP in headers sent to the server, I haven't found a way to get the real IP address.
The Connection.Ip property is set to 127.0.0.1 (localhost) and the Connection.HeadersResponse stringlist don't contain any X- value

So is there a way to get this information from each connection and how ?
Found it !
It's in TsgcWSConnection_Base_Indy(Connection).HeadersRequest - but not accessible in base class therefore need a static cast to access it.

Therefore, consider this as a feature request to have it accessible through a regular TsgcWSConnection
·
4 months ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

The TsgcWSConnection class is shared with the Server and Client components, if you want to access to the fields of the Server component, cast using the class TsgcWSConnectionServer. You can find more info here:

https://www.esegece.com/help/sgcWebSockets/#t=Components%2FTsgcWebSocketServer%2FHandShake%2FServer_Read_Headers_from_Client.htm

Thanks for the feedback.

Kind Regards,
Sergio
·
4 months ago
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post