Nginx Routing Based on Header Upgrade

Nginx Routing Based on Header Upgrade

Some Command I need
>sudo sbin/nginx -s reload
Reload the configuration file and restart the nginx

>sudo sbin/nginx -t
Test and check if my statements in conf/nginx.conf is correct.

>sudo sbin/nginx
Just Start the nginx process

Here is my configuration.

location / {   

   proxy_pass                  http://contentcenter2;    

   if ($http_x_header) {        

       proxy_pass              http://contentcenter1;    

   }
}

The idea is that first of all, make proxy_pass have default value.
Then check the header, if we have the customer header X_HEADER, we will go to another proxy_pass value, which point to another server URL.



References:
http://sillycat.iteye.com/blog/2074417
http://sillycat.iteye.com/blog/2074422


猜你喜欢

转载自sillycat.iteye.com/blog/2075245
今日推荐