Welcome! Log In Create A New Profile

Advanced

Only lookup geoip when necessary?

Posted by Mark 
Only lookup geoip when necessary?
November 15, 2011 05:03PM
I want to do a geoip lookup only when a "location" cookie doesn't exist, and then only when Nginx isn't serving the file for me. Everything works except for the conditional (I know about the IfisEvil etc - this is shown for the logic ....)

Is there a way to achieve what I am trying to do in this example?

location @app {
if ($http_cookie !~* "location") {
proxy_set_header Country-Name $geoip_country_name;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://upstream_server;
}

Many thanks.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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