Welcome! Log In Create A New Profile

Advanced

Re: How can i get ip and port under forward proxy

Maxim Dounin
June 05, 2013 08:20AM
Hello!

On Wed, Jun 05, 2013 at 06:26:25AM -0400, honwel wrote:

> Hi, there
>
> I want to get ip and port under forward proxy use NGINX, a forward proxy
> sketch like this:
>
> [Client ]-> [NGINX] -> [Internet]
>
> so i want to get proxy's ip and port . i have try and made some
> modifications to the source code including ngx_http_upstream.c
> ngx_event_connect.c , there are some details: 1、add local_socket variable to
> get socket fd in ngx_event_connect_peer() 2、add local_sockaddr to get
> sockaddr structure in ngx_http_upstream_process_header(), because in this
> function the proxy had connected(connect() in ngx_event_connect_peer() is
> nonblocking) to the upstream(web, e.g. google.com) 3、add a $upstream_laddr
> variable in the ngx_http_upstream.c as ngx_http_upstream_addr_variable()
> function. 4、set log property like:

[...]

> Does i have made mistake for code or worng understanding of NGINX event
> model. how can make this work correctly to get IP and Port.

You may want to show your code if you want us to help.

Note well: upstream connection socket's file descriptor is
available via u->peer.connection->fd after a successful
ngx_event_connect_peer() call in ngx_http_upstream_connect(). At
this point, local sockaddr of the socket should be also valid as
connect() was already called.

--
Maxim Dounin
http://nginx.org/en/donation.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How can i get ip and port under forward proxy

honwel June 05, 2013 06:26AM

Re: How can i get ip and port under forward proxy

Maxim Dounin June 05, 2013 08:20AM

Re: How can i get ip and port under forward proxy

honwel June 05, 2013 09:10PM

Re: How can i get ip and port under forward proxy

Maxim Dounin June 06, 2013 09:04AM

Re: How can i get ip and port under forward proxy

honwel June 06, 2013 09:29PM

Re: How can i get ip and port under forward proxy

Maxim Dounin June 06, 2013 10:06PM

Re: How can i get ip and port under forward proxy

honwel June 05, 2013 09:37PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 246
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready