admin管理员组文章数量:1295859
I followed this advice from the official docs to force SSL:
define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
Wordpress runs in a docker container. When it starts it says
WARNING: The _SERVER variable is not set. Defaulting to a blank string.
And Wordpress' logs show this:
PHP Fatal error: Assignments can only happen to writable values in /var/www/html/wp-config.php
So _SERVER
is the problem. How do I fix this?
I followed this advice from the official docs to force SSL:
define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
Wordpress runs in a docker container. When it starts it says
WARNING: The _SERVER variable is not set. Defaulting to a blank string.
And Wordpress' logs show this:
PHP Fatal error: Assignments can only happen to writable values in /var/www/html/wp-config.php
So _SERVER
is the problem. How do I fix this?
- Did you find a solution? – Jesus Iniesta Commented Nov 17, 2020 at 16:23
1 Answer
Reset to default 2If you are using docker-compose and the WORDPRESS_EXTRA_CONFIG
as I was, when I stumbled across that error, the solution would be to use double-dollar-sign notation as described in a corresponding issue in the docker-compose repo on GitHub.
This additional environment variable is described in the "How to use this image" of the official image documentation on hub.docker.
Your snippet in the context of a docker-compose.yml
would be:
wordpress:
image: wordpress:latest
environment:
WORDPRESS_CONFIG_EXTRA: |
define('FORCE_SSL_ADMIN', true);
if (strpos($${_SERVER}['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$${_SERVER}['HTTPS']='on';
of course extended with an appropriate database container and corresponding environment variables for database and user name and passwords.
This will result in the environment variable _SERVER
to only expand in the container. If you use a single dollar sign, docker-compose will try to populate the value of the specified environment variable from the surrounding context into the compose file as described in the official compose docs.
本文标签: phpForce SSL using FORCESSLADMIN
版权声明:本文标题:php - Force SSL using FORCE_SSL_ADMIN 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741624907a2389027.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论