7 messages in ru.sysoev.nginxConditionals in fastcgi config
FromSent OnAttachments
Andrew DeasonOct 17, 2007 1:00 pm 
RoxisOct 17, 2007 2:18 pm 
Andrew DeasonOct 17, 2007 2:49 pm 
Maxim DouninOct 18, 2007 1:49 am 
Igor ClarkOct 30, 2007 9:04 am 
Maxim DouninOct 30, 2007 9:50 am 
Igor ClarkOct 30, 2007 11:14 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Conditionals in fastcgi configActions...
From:Igor Clark (igor@public.gmane.org)
Date:Oct 30, 2007 9:04:22 am
List:ru.sysoev.nginx

Hi Igor and nginx people,

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.

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 http://outside.dns.name/index.php is proxied through to http://inside.dns.name/index.php.

This means that the SERVER_NAME value seen by the web application (PHP script in this case) is inside.dns.name.

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.

We've achieved this straightforwardly by setting

fastcgi_param SERVER_NAME $http_x_forwarded_host;

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.

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.

So ideally I'd like to do something like:

fastcgi_param SERVER_NAME $server_name; if ($http_x_forwarded_host) { fastcgi_param SERVER_NAME $http_x_forwarded_host; }

but: firstly "fastcgi_param" is not supported inside "if", and secondly I don't know how or if this "overriding" would work.

What's the best way to do this, please?

Thanks very much Igor