Nginx + apache : REMOTE_ADDR and REMOTE_HOST bug

Gena Makhomed gmm at csdoc.com
Wed Aug 31 10:59:14 UTC 2011


On 31.08.2011 10:03, Albuquerque Rui wrote:

> While accessing the page directly from apache i've got the good
> values too. But when i pass by nginx then apache ( mod_rpaf ) the
> hostname is not right :(

in request from nginx to apache backend - you set correct
client hostname in the X-Forwarded-Host or X-Host header?

RPAFsethostname on;

means what you must provide desirable client hostname:

source of mod_rpaf-0.6\mod_rpaf-2.0.c
-------------------------------------

if (cfg->sethostname) {
     const char *hostvalue;
     if (hostvalue = apr_table_get(r->headers_in, "X-Forwarded-Host")) {
         /* 2.0 proxy frontend or 1.3 => 1.3.25 proxy frontend */
         apr_table_set(r->headers_in, "Host", apr_pstrdup(r->pool, 
hostvalue));
         r->hostname = apr_pstrdup(r->pool, hostvalue);
         ap_update_vhost_from_headers(r);
     } else if (hostvalue = apr_table_get(r->headers_in, "X-Host")) {
         /* 1.3 proxy frontend with mod_proxy_add_forward */
         apr_table_set(r->headers_in, "Host", apr_pstrdup(r->pool, 
hostvalue));
         r->hostname = apr_pstrdup(r->pool, hostvalue);
         ap_update_vhost_from_headers(r);
     }
}

-- 
Best regards,
  Gena



More information about the nginx mailing list