Nginx with Accept-Language support

Utilizing the Accept-Language header in nginx requires a module. This is documentation about how to make it work.

I wanted to use this header to server different files for different languages. You might easily imagine having a set of static files like index_en.html, index_es.html and index_ja.html and wanting to serve one of these depending on the preferences in the Accept-Language header.

This was done on a brand-spanking-new Ubuntu 14.04 Server Edition VM.

Installing #

Get the source for nginx

mkdir nginx_src
cd nginx_src
wget http://nginx.org/download/nginx-1.6.0.tar.gz

Extract it

tar -xvf nginx-1.6.0.tar.gz

Get the accept_language_module

cd ~
git clone https://github.com/giom/nginx_accept_language_module.git

or

wget https://github.com/giom/nginx_accept_language_module/archive/master.zip
unzip master.zip
mv nginx_accept_language_module{-master,}

Install the dependencies

sudo apt-get install libpcre3 libpcre3-dev zlib1g-dev make libssl-dev

Build nginx with the new module

cd nginx_src/nginx-1.6.0
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --with-http_ssl_module --with-http_gunzip_module --with-http_realip_module --with-http_gzip_static_module --with-http_secure_link_module --group=nginx --add-module=$HOME/nginx_accept_language_module/
make
sudo make install

Now you have nginx compiled to allow you to use the Accept-Language header.

How to use it #

See http://wiki.nginx.org/AcceptLanguageModule#Example_configuration

Sources #

http://wiki.nginx.org/Install

http://wiki.nginx.org/AcceptLanguageModule

http://xmodulo.com/2014/01/compile-install-nginx-web-server.html

 
12
Kudos
 
12
Kudos

Now read this

Block Size, the history of choosing 1MB

The bitcoin block size is 1MB. Why was this number chosen? The reasoning of the past may have application to the reasoning in the present and future. Original Code # The block size is defined in code by MAX_BLOCK_SIZE and is 1000000... Continue →