May 112011

Instead of writing multiple server blocks repeatedly in configuration, we can simplified configuration using nginx map module


    map_hash_bucket_size 128;

    map $http_host $backend_servers {

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;

	server {
		location / {
			proxy_pass  http://$backend_servers

source: taken from nginx mailinglist

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>




This site uses Akismet to reduce spam. Learn how your comment data is processed.