Welcome! Log In Create A New Profile

Advanced

Re: Linux netfilter NAT variable

April 01, 2011 01:08PM
Hi,
I have interests in this variable.
Would you please send me the whole patch ?
I will test it.
Thanks in advance.

BR,
DeltaY

2010/12/8 Roman Vasilyev <roman@anchorfree.com>:
> Hi,
>
> I've added very useful for me variable which helps get destination IP from
> netfilter NAT table, in this case we don't need to make extra resolving
> requests, adding code for this variable, is it useful for other?
> Also I have question what best attributes for this var? I'm using
> NGX_HTTP_VAR_NOHASH.
>
> static ngx_int_t
> ngx_http_orig_ip(ngx_http_request_t *r, ngx_http_variable_value_t *v,
>    uintptr_t data)
> {
>  struct sockaddr_in addr;
>  socklen_t addr_sz = sizeof(addr);
>  bzero(&addr, addr_sz);
>  addr.sin_family = AF_INET;
>
>  if (getsockopt(r->connection->fd, SOL_IP, SO_ORIGINAL_DST, &addr, &addr_sz)
> != 0) {
>    ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
>    "Couldn't read SO_ORIGINAL_DST from socket errno: %d", errno);
>    return NGX_ERROR;
>  }
>
>  v->data = ngx_palloc(r->pool, NGX_INET_ADDRSTRLEN);
>  v->len=ngx_inet_ntop(AF_INET, &addr.sin_addr, v->data,
> NGX_INET_ADDRSTRLEN);
>  return NGX_OK;
> }
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>

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

Linux netfilter NAT variable

Roman Vasilyev December 07, 2010 09:56PM

Re: Linux netfilter NAT variable

deltay April 01, 2011 01:08PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 222
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