Open strarsis opened 2 weeks ago
Makes sense to me. I assume it should be added right after the include here? https://github.com/roots/trellis/blob/9a45aab9dad405f849ab22648348444781121cfb/roles/wordpress-setup/templates/wordpress-site.conf.j2#L257-L258
Want to contribute the fix?
Version
1.22.1
What did you expect to happen?
PHP
$_SERVER['SERVER_NAME']
is assigned the correct domain that is requested, not the first (or random?) one inserver_name
innginx
site configuration.This prevents redirection from redirection plugins.
What actually happens?
PHP
$_SERVER['SERVER_NAME']
is assigned incorrect domain, as the first (or random?) one inserver_name
innginx
site configuration.Steps to reproduce
print_r($_SERVER);
inindex.php
). Note that theSERVER_NAME
field in$_SERVER
is not correct for all other requested canonical domains except for one (usually the first listed one).Note that the
SERVER_NAME
is not always the first canonical domain, apparently this can change, which caused issues with a redirection plugin that redirected from the wrong canonical domain.System info
Ubuntu LTS
Log output
No response
Please confirm this isn't a support request.
Yes
Context
In order to fix the passed
SERVER_NAME
,$host
instead of$server_name
has to be used:In
fastcgi_params
configuration file included by the sites,$server_name
is used:And
$server_name
is the wrong value:(from Michael Hampton in https://serverfault.com/a/706439/958731).
As
fastctgi_params
is a default configuration file shipped withnginx
, it makes sense to override theSERVER_NAME
field after that file was included, in order to override it effectively: