[问题] Nginx header问题

楼主: raynoz (Rayoz)   2023-12-13 01:16:12
是这样的 我已经架设好nginx 并添加geoip2 module 以及设定好mmdb
测试连到nginx已经会取得我要的header
这是部分config
location /info {
add_header X-Real-IP $remote_addr;
add_header X-GeoIP-Country-Code $geoip2_country_code;
add_header X-GeoIP-Country-Name $geoip2_data_country_name;
add_header X-GeoIP-Data-Country-Code $geoip2_data_country_code;
add_header X-GeoIP-Data-City-Name $geoip2_data_city_name;
add_header X-GeoIP-Continent-Code $geoip2_continent_code;
add_header X-GeoIP-Data-Province-Name $geoip2_data_province_name;
add_header X-GeoIP-Data-Province-Isocode $geoip2_data_province_isocode;
}
想请问如果我proxy pass到后端(这边拿另一台nginx 192.168.1.2来模拟当后端)
location /info {
proxy_pass http://192.168.1.2
并且想在后端的access.log上可以看到这些header
该怎么做呢
作者: changchichun (Eric Chang)   2023-12-14 10:30:00
set_header ?
作者: Jerr (身为老爸老妈噜..)   2023-12-14 17:22:00
后端也是 nginx? access_log 用的 log_format 加变量上去header对应到的变量应该是 $http_x_* *是转成全底线小写$http_x_geoip_country_code 看看可以吗?

Links booklink

Contact Us: admin [ a t ] ucptt.com