Re: Цепочка nginx proxy

Gena Makhomed gmm at csdoc.com
Mon Mar 23 22:07:30 UTC 2015


On 23.03.2015 23:50, MereMortals wrote:

> Есть такая схема
>
> клиент <->nginx_1 <->nginx_2<->apache
>
> На nginx_1 настрен GeoIP и в настройках прописано:
>
> proxy_set_header Host $host;
> proxy_set_header X-Forwarded-For $remote_addr;
> proxy_set_header X-Real-IP $my_real_ip;
> proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code;
> proxy_set_header GEOIP_COUNTRY_CODE3 $geoip_country_code3;
> proxy_set_header GEOIP_COUNTRY_NAME $geoip_country_name;
> proxy_set_header GEOIP_CITY_COUNTRY_CODE $geoip_city_country_code;
> proxy_set_header GEOIP_CITY_COUNTRY_CODE3 $geoip_city_country_code3;
> proxy_set_header GEOIP_CITY_COUNTRY_NAME $geoip_city_country_name;
> proxy_set_header GEOIP_CITY_COUNTRY_NAME2 $geoip_city_country_name;
> proxy_set_header GEOIP_REGION $geoip_region;
> proxy_set_header GEOIP_CITY $geoip_city;
> proxy_set_header GEOIP_POSTAL_CODE $geoip_postal_code;
> proxy_set_header GEOIP_CITY_CONTINENT_CODE $geoip_city_continent_code;
> proxy_set_header GEOIP_LATITUDE $geoip_latitude;
> proxy_set_header GEOIP_LONGITUDE $geoip_longitude;
>
> Но почему то до apache не доходят заголовки GEOIP_*, но доходят
> X-Forwarded-For и X-Real-IP. На вход у nginx_2 заголовки приходят, проверено
> через tcpdump, но почему то он их не проксирует. В чем может быть причина?

Потому что:
http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers
http://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers

Если вместо proxy_set_header GEOIP_REGION $geoip_region;
написать proxy_set_header GeoIP-Region $geoip_region;
то такой заголовок тоже пройдет нормально.

-- 
Best regards,
  Gena



Подробная информация о списке рассылки nginx-ru