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

(WIP) PROXY protocol support #110

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

(WIP) PROXY protocol support #110

wants to merge 11 commits into from

Conversation

chendo
Copy link

@chendo chendo commented Feb 10, 2015

This PR is a hack that implements PROXY protocol (http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt) which allows upstream TCP servers to be notified the original IP and port of the client.

Tested with nginx 1.7.9.

Sorry about whitespace changes and probable code quality as I'm not familiar with C and this is my first bit of work on an nginx module.

The function in question: https://github.com/yaoweibin/nginx_tcp_proxy_module/pull/110/files#diff-439a7558cb55631857d62112acec7449R237

Example configuration:

tcp {
  upstream backend {
    server 127.0.0.1:4221;

    accept_proxy on;
  }

  server {
    listen 4222;
    proxy_pass backend;
  }
}

Issues:

  • The destination IP and port is wrong. I can't seem to find a proper reference to the socket the connection was accepted on. We don't use the destination IP/port anyway so it's not critical for us.

@yaoweibin
Copy link
Owner

Remove the useless spaces is good for me. Thank you.

I'm reviewing this pull request.

c->log->action = "ngx_tcp_proxy_send_proxy_protocol";

client = (struct sockaddr_in*)s->connection->sockaddr;
listener = (struct sockaddr_in*)s->connection->listening->sockaddr; // doesn't appear to be correct
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try the s->connection->local_sockaddr, it should store the destination address.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave it a go, doesn't seem to return the correct values either. IP is 0.0.0.0 and the port is not the port defined in the configuration. Not that important anyway IMO

@aderumier
Copy link

Hi, any news about this PR ?

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

Successfully merging this pull request may close these issues.

3 participants