Thursday, 31 July 2025
  2 Replies
  16.4K Visits
  Subscribe
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 ?
4 months ago
·
#2333
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
·
#2334
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
  • Page :
  • 1
There are no replies made for this post yet.
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below.
Supported: gif,jpg,png,jpeg,zip,rar,pdf,pas,dfm,dpr,dproj,dpk,txt,log
· Insert · Remove
  Upload Files (Maximum 10MB)