Skip to content

Get real client IP address behind the reverse proxy #285

@amiart

Description

@amiart

I'm using the nginx server as a reverse proxy for Qt TreeFrog as described on this page:

https://www.treefrogframework.org/en/user-guide/cooperation-with-the-reverse-proxy-server/

The problem is that in this case the TActionController::clientAddress() and TWebSocketEndpoint::peerAddress() functions return the proxy address instead of the client's IP address.

In nginx, you can add an X-Forwarded-For header containing the client's IP address:

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

but unfortunately Qt TreeFrog does not have functionality similar to that of mod_remoteip Apache server:

https://httpd.apache.org/docs/current/es/mod/mod_remoteip.html

Would it be possible to add an option in the TreeFrog configuration to define the name of the HTTP header containing the client's original IP address (RemoteIPHeader) and the list of trusted proxy (RemoteIPTrustedProxy) ? The TActionController::clientAddress() function would return the client's IP address instead of the proxy IP address if the proxy is trusted.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions