Score:0

Dockerized wordpress behind Nginx proxy pass on host redirects to / in admin panel after logging in

ca flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.