Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging client real IP while running ttyd under a reverse proxy #1259

Open
TissuePowder opened this issue Nov 23, 2023 · 2 comments
Open

Logging client real IP while running ttyd under a reverse proxy #1259

TissuePowder opened this issue Nov 23, 2023 · 2 comments
Labels

Comments

@TissuePowder
Copy link

I am running ttyd in my host machine (that is, not under docker, vm or bridged network) with the following command:

$ ./ttyd.x86_64 -i 127.0.0.1 -p 9000 -W command

It is then reverse proxied through nginx. Part of the relevant nginx config is below:

proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;

Requests are logged in the terminal as:

HTTP / - 127.0.0.1
WS   /ws - 127.0.0.1, clients: 1

How do I get ttyd to log the clients' real ip instead of 127.0.0.1? I should mention that passing or not passing the -i option doesn't (and shouldn't) have any effect here.

@tsl0922
Copy link
Owner

tsl0922 commented Mar 26, 2024

It's not supported yet, but why? you can already log the real ip with nginx.

@TissuePowder
Copy link
Author

I tagged this as a question because I wasn't sure if it just wasn't supported or I just didn't know how to. So your comment answers my question.

But either way, even though nginx can log ip fine, it would be nice too to be able to see the ip on ttyd logs on terminal. I am forwarding he real-ip related headers from nginx, ttyd just needs to read the values from the header and print it on terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants