0

I am attempting to run Wordpress on Docker on my VPS. Since I run some additional web apps, I have setup Nginx proxy pass to route requests to each of them. As such I have setup the same for this Wordpress setup by proxy passing /blog to the Wordpress container running on port 8198.

Everything seems to work fine when installing and logging in, even the admin panel opens. But if I click on any link in the admin panel I see that the URL no longer has the /blog URI. That is /blog/wp-admin/* becomes /wp-admin/*. Also, mousing over the links also shows that the base URI /blog is missing and is instead /wp-admin. This results in a 404 error and I have to manually add /blog to the URL to make it work.

My Nginx config is as follows:

 location /blog/ {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_pass http://127.0.0.1:8198/;
        }

Wordpress is run using the following docker-compose.yml file:

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8198:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: REDACTED
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_CONFIG_EXTRA: "define('WP_HOME', 'https://mydomain/blog'); define('WP_SITEURL', 'https://mydomain/blog');"
    volumes:
      - wordpress:/var/www/html

  db:
    image: mariadb/server:10.5
    restart: always
    environment:
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: REDACTED
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

Is there any configuration I am missing? I suspect that this has something to do with the Wordpress setup rather than in Nginx but I am not sure.

Please help.

Desmond27
  • 1
  • 2

0 Answers0