View Single Post
  #6  
Old 9th July 2013, 22:28
cbj4074 cbj4074 is offline
Senior Member
 
Join Date: Nov 2010
Posts: 392
Thanks: 29
Thanked 58 Times in 50 Posts
Default

A quick follow-up after making some progress.

With the objective "to redirect requests for all subdomains (other than www) to www subdomain", I was able to fix all of the "unexpected" SEO redirection issues by setting Auto-Subdomain to "*." and setting SEO Redirect to "* => www.domain.tld.

As it turns-out (and as usual), ISPConfig is behaving "correctly".

That leaves just the SERVER_NAME CGI variable problem. With the above settings, the server_name directive looks like this:

Code:
server_name example2.com *.example2.com;
When I var_dump() the $_SERVER['SERVER_NAME'] from within PHP, the value is example2.com. (I should note an important correction to an assumption made in my initial post: it seems that nginx doesn't always use the first server_name value in a list of several values; unfortunately, I don't know by what criteria nginx decides which value to assign to its $server_name configuration variable, which is later passed to CGI.)

Of course, as stated previously, I need this value to be www.example2.com, in order to secure my application against misconfiguration or malice.

I was able to do this by overwriting and hard-coding the fastcgi_param that is defined within ISPC's nginx vhost template:

Code:
location @php {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_param	SERVER_NAME		www.example2.com;
            # [...]
}
Obviously, this approach is unacceptable because ISPC will overwrite the change whenever the vhost is modified via the GUI.

Ultimately, I am wondering if there is a "correct" means by which to achieve the same. I'm failing to see how I might overwrite the SERVER_NAME value within the vhost's "nginx Directives" field, given that the "location @php" block is already closed by the time those directives are written to the configuration file.

Thanks again, Till.

EDIT:

I'm all set, regarding the SERVER_NAME value; the following works:

Code:
fastcgi_param	SERVER_NAME		www.$server_name;

Last edited by cbj4074; 10th July 2013 at 16:06.
Reply With Quote