<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hi Igor and nginx people,<DIV><BR class="khtml-block-placeholder"></DIV><DIV>We use nginx as a front end on various development machines in our studio to route to installations of Apache 1, Apache 2, PHP/FCGI, and Ruby/Mongrel on each machine, as appropriate depending on SERVER_NAME conventions, using our private DNS domain.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>We have some circumstances under which we need to grant external access to machines with this setup, and we do this using Apache reverse proxy on the firewall. (Eventually this will be replaced by nginx, but it's got a lot of legacy stuff which will need some time set aside for converting.) Hence <A href="http://outside.dns.name/index.php">http://outside.dns.name/index.php</A> is proxied through to <A href="http://inside.dns.name/index.php">http://inside.dns.name/index.php</A>.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>This means that the SERVER_NAME value seen by the web application (PHP script in this case) is inside.dns.name.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>We often configure web applications on a per-host basis, so that e.g. database configuration information is kept in a hash keyed by SERVER_NAME values. This means we need to have SERVER_NAME contain the outside.dns.name.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>We've achieved this straightforwardly by setting</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>fastcgi_param<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>SERVER_NAME<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>$http_x_forwarded_host;</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>which works nicely, but means that all applications responding to different DNS names (not viewed externally via Apache reverse proxy) fail, because they don't have an X-FORWARDED-HOST header, thus fall back to the local machine hostname, which is not in the configuration hash.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>We can get round this by creating separate server {} configurations for applications which need to be served behind a remote reverse proxy, but that defeats the object of our generic per-host configuration based on hostnames.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>So ideally I'd like to do something like:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>fastcgi_param<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>SERVER_NAME<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>$server_name;</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>if ($http_x_forwarded_host) {</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>fastcgi_param<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>SERVER_NAME<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>$http_x_forwarded_host;</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>but: firstly "fastcgi_param" is not supported inside "if", and secondly I don't know how or if this "overriding" would work.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>What's the best way to do this, please?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks very much</DIV><DIV>Igor</DIV><DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>--</DIV><DIV>Igor Clark // POKE // 10 Redchurch Street // E2 7DD // +44 (0)20 7749 5355 // <A href="http://www.pokelondon.com">www.pokelondon.com</A></DIV></SPAN></SPAN></SPAN><DIV><BR class="khtml-block-placeholder"></DIV></SPAN><DIV>--</DIV><DIV>Get on Board with WWF for a stronger Climate Change Bill</DIV><DIV><A href="http://getonboard.wwf.org.uk">http://getonboard.wwf.org.uk</A>/</DIV><DIV><BR class="khtml-block-placeholder"></DIV></SPAN></SPAN></SPAN><BR class="Apple-interchange-newline"></SPAN></SPAN> </DIV><BR></DIV></BODY></HTML>