How to make nginx works with Geo IP?

NGINX GeoIP Installation: Follow these steps to install GeoIP with nginx: wget tar -zxvf GeoIP.tar.gz cd GeoIP-1.4.8/ ./configure make make install echo ‘/usr/local/lib’ > /etc/ yum install gcc pcre-devel.x86_64 openssl-devel.x86_64 yum install readline-devel pcre-devel openssl-develWe are using openresty – nginx here:wget tar xzvf ngx_openresty- cd ngx_openresty- ./configure –with-luajit –with-http_geoip_module gmake gmake installwget -O /usr/local/share/GeoIP/GeoIP.dat.gz gunzip /usr/local/share/GeoIP/GeoIP.dat.gz […]

Nginx Openresty Get/Set Cookies using LUA.

To set cookies using lua while using nginx_lua module in openresty/nginx server, use this code: local expires = 3600 * 24  — 1 day ngx.header[“Set-Cookie”] = “session=demo; Path=/; Expires=” .. ngx.cookie_time(ngx.time() + expires) This will set cookie session = demo for 1 day from current time on path /.

Nginx Proxy requests are redirecting to upstream name.

If you are using nginx as a reverse proxy and having the redirection issues to upstream name when proxy request results in 301,302 redirects, e.g. is proxied by backend upstream i.e. upstream backend { server; } location / { proxy_pass http://backend; } and the requests are getting ended eith http://backend/new.html, than you need to sepecify the proxy_headerr […]

Nginx allow cross domain ajax requests

To enable Nginx for Cross Origin calls add this in nginx configuration for the domain  : location /{ add_header ‘Access-Control-Allow-Origin’ ‘’; add_header ‘Access-Control-Allow-Credentials’ ‘true’; add_header ‘Access-Control-Allow-Methods’ ‘GET’; } That’s it, it will enable GET requests from to the configured domain.