Dockerfile
Dockerfile copied to clipboard
Question : [Nginx] How to change value of $_SERVER['SERVER_NAME'] from nginx conf ?
in vhost.conf we have :
server_name _ <ALIAS_DOMAIN> docker;
in /opt/docker/etc/nginx/vhost.conf, in a running container, I have the substitution of <ALIAS_DOMAIN>
working well, but in a PHP app, the value of $_SERVER['SERVER_NAME']
is still _
, as it should be.
What would be the best approach to get my WEB_ALIAS_DOMAIN
env var used in PHP's $_SERVER['SERVER_NAME']
?
I tried to write
fastcgi_param SERVER_NAME <ALIAS_DOMAIN>;
in a conf file in vhost.common.d but it does'nt work.
Thanks
I am experiencing the exact same error.
PHP's sever name variable is set to _
on my test site.
In a workaround, I added the following code to /vhost.common.d/10-php.conf to get the correct domain name inside the container.
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SERVER_NAME $host;
}
Another workaround: Overwrite vhost.conf in your Dockerfile and set the expected server name as first server_name
argument.
The real question is however why there is a _
in the first place?
Any updates? How to change $_SERVER without editing vhost manually?