I have looked through several related issues, but could not find a solution. It only happens when I'm at /wp-admin.
I get a sort of 'redirect' when I access wp-admin. Seems like a pushState. Found this thing:
<link id="wp-admin-canonical" rel="canonical" href="https://example.com/wp-admin/">
...which is incorrect, because I want it to be in a subdirectory. Where does this tag get its information from? I have set WP_HOME and WP_SITEURL variables (see below).
docker-compose.yml:
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8010:80"
restart: always
environment:
WORDPRESS_CONFIG_EXTRA: |
define('WP_HOME', 'https://example.com/subdir');
define('WP_SITEURL', 'https://example.com/subdir');
define('DOMAIN_CURRENT_SITE', 'example.com');
define('PATH_CURRENT_SITE', '/subdir/');
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
EDIT: Because I'm using nginx, let me just post my config for that too...
location /subdir/ {
proxy_pass http://localhost:8010/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
I recommend you ditch WORDPRESS_CONFIG_EXTRA entirely and instead simply use workdir: /var/www/html/subdir (see https://github.com/docker-library/wordpress/issues/221#issuecomment-356454850).
The directive is working_dir, but it works perfectly now! Thank you for your help!
Most helpful comment
I recommend you ditch
WORDPRESS_CONFIG_EXTRAentirely and instead simply useworkdir: /var/www/html/subdir(see https://github.com/docker-library/wordpress/issues/221#issuecomment-356454850).