I have nginx.conf with following structure:
http {
    [ ... ]
    server {
        [ ... ]
        location ~ \.php$ {
            fastcgi_pass  unix:/run/php/php7.0-fpm.sock;
            fastcgi_split_path_info  ^(.+\.php)(/.*)$;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param  SERVER_NAME $host;
            fastcgi_read_timeout  3000;
            include  fastcgi_params;
        }
    }
}
This nginx runs inside Docker so it has no idea, which domain is linked to it (there is nginx reverse proxy on hosting system). But I have a problem that when I try to acces $_SERVER['SERVER_NAME'] from PHP, it's empty... How can I set it to constant value? When I tried:
fastcgi_param  SERVER_NAME example.com
it's still empty.
Please note that I have to use SERVER_NAME, because it's in 3rd part code.
Multiple fastcgi_param statements (at the same block level) setting the same parameter will silently use the value from the last statement. This includes statements read via an include directive.
Always declare fastcgi_param statements after the include fastcgi_params; statement to avoid any ambiguity in your configuration files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With