proxy_pass based on (possibly changed) $host

Dave Bailey dave at
Wed Jan 28 13:52:24 MSK 2009


I am porting a lighttpd module that I wrote to nginx.  I am new to
nginx.  I would like to know if it is possible to choose the
proxy_pass backend from the Host header within a server.  In lighttpd,
this is possible by:

$SERVER["socket"] == ":80" {
  $HTTP["host"] == "" {
    proxy-core.backends = ( "" )
  $HTTP["host"] == "" {
    proxy-core.backends = ( "" )

The module that I am porting to nginx will sometimes update the Host
header such that a different proxy backend should be chosen.  For
example, a request from a particular IP address to
might be updated such that its Host header changes from to, and thus it is served by the backend.  Is
there a way to specify a relationship between $host and proxy_pass in
nginx.conf within the same server { ... }?


More information about the nginx mailing list