I've moved an existing Wordpress blog to docker using the official wordpress
and mysql
images as shown below:
version: "3.9"
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
volumes:
- ./wordpress_data:/var/www/html
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DEBUG: 1
volumes:
db_data: {}
wordpress_data: {}
The server runs nginx
as a reverse proxy, which does the HTTPS protocol termination and redirects the traffic to the docker container on localhost
port 8000
:
location /blog {
proxy_pass http://localhost:8000;
# Do not buffer responses from proxied server
proxy_buffering off;
# The HTTP protocol for proxying (1.0 by default). Needs to be 1.1 for websockets and keepalive
proxy_http_version 1.1;
proxy_set_header Host $host;
# Forward the real visitor remote IP address to the proxied server
proxy_set_header X-Real-IP $remote_addr;
# A list containing the IP addresses of every server the client has been proxied through
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# When used inside an HTTPS server block, each HTTP response from the proxied server is rewritten to HTTPS.
proxy_set_header X-Forwarded-Proto $scheme;
# The original port requested by the client
proxy_set_header X-Forwarded-Port 443;
# Defines the original host requested by the client.
proxy_set_header X-Forwarded-Host $host;
}
When trying to access the blog from a web browser, the only resource that loads is index.php. All other resources like css
and image files return 404
:
What could be the reason for this?
Edit 1: result of listing /var/www/html
from the wordpress
container:
geschema@electrolite-22:~/docker/blog$ docker container exec -it ad276615ba09 bash
root@ad276615ba09:/var/www/html# ls -al
total 244
drwxr-xr-x 5 www-data www-data 4096 Jul 16 10:03 .
drwxr-xr-x 1 root root 4096 Jun 23 07:22 ..
-rw-r--r-- 1 www-data www-data 261 Jun 24 01:57 .htaccess
-rw-r--r-- 1 www-data www-data 405 Feb 6 2020 index.php
-rw-r--r-- 1 www-data www-data 19915 Jan 1 2022 license.txt
-rw-r--r-- 1 www-data www-data 7401 Mar 22 21:11 readme.html
-rw-r--r-- 1 www-data www-data 7165 Jan 21 2021 wp-activate.php
drwxr-xr-x 9 www-data www-data 4096 May 24 19:02 wp-admin
-rw-r--r-- 1 www-data www-data 351 Feb 6 2020 wp-blog-header.php
-rw-r--r-- 1 www-data www-data 2338 Nov 9 2021 wp-comments-post.php
-rw-rw-r-- 1 www-data www-data 5480 Jun 24 01:56 wp-config-docker.php
-rw-r--r-- 1 www-data www-data 3001 Dec 14 2021 wp-config-sample.php
-rw-r--r-- 1 www-data www-data 5584 Jun 28 18:00 wp-config.php
drwxr-xr-x 6 www-data www-data 4096 Jul 16 11:42 wp-content
-rw-r--r-- 1 www-data www-data 3943 Apr 28 09:49 wp-cron.php
drwxr-xr-x 26 www-data www-data 16384 May 24 19:02 wp-includes
-rw-r--r-- 1 www-data www-data 2494 Mar 19 20:31 wp-links-opml.php
-rw-r--r-- 1 www-data www-data 3973 Apr 12 01:47 wp-load.php
-rw-r--r-- 1 www-data www-data 48498 Apr 29 14:36 wp-login.php
-rw-r--r-- 1 www-data www-data 8577 Mar 22 16:25 wp-mail.php
-rw-r--r-- 1 www-data www-data 23706 Apr 12 09:26 wp-settings.php
-rw-r--r-- 1 www-data www-data 32051 Apr 11 11:42 wp-signup.php
-rw-r--r-- 1 www-data www-data 4748 Apr 11 11:42 wp-trackback.php
-rw-r--r-- 1 www-data www-data 3236 Jun 8 2020 xmlrpc.php
Edit 2: excerpt from the wordpress
container logs, where we can see that only /blog
returns the status code 200
:
90.19.131.1 - - [16/Jul/2022:13:33:28 +0000] "GET /blog/ HTTP/1.1" 200 17386 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
90.19.131.1 - - [16/Jul/2022:13:33:28 +0000] "GET /blog/wp-includes/js/jquery/jquery-migrate.min.js?ver=3.3.2 HTTP/1.1" 404 35182 "https://example.com/blog/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
90.19.131.1 - - [16/Jul/2022:13:33:28 +0000] "GET /blog/wp-content/themes/twentyfifteen/genericons/genericons.css?ver=20201208 HTTP/1.1" 404 35182 "https://example.com/blog/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
90.19.131.1 - - [16/Jul/2022:13:33:28 +0000] "GET /blog/wp-content/themes/twentyfifteen/css/blocks.css?ver=20190102 HTTP/1.1" 404 35182 "https://example.com/blog/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
https://<mydomain>.com/blog
. Is that correct or should those be configured tohttp://localhost:8000?