After docker deploys nginx reverse proxy wordpress, it adds a layer of /wp access path and cannot access it.

  docker, question

Now nginx runs on one container and wordpress runs on one container (wordpress is the latest official image dragged on dockerhub and is a php program running on apache server). The two containers are independent of each other. Want tohttp://192.168.8.107/wp/This address is accessed to wordpresshttp://192.168.8.107: 8000 visits).

Nginx partial code

server {
 # Listening Port Number
 listen  80;
 
 # Service Name
 server_name  192.168.8.107;
 
 location /wp/ {
 root   html;
 
 index   index.html  index.htm  index.php ;
 
 # Reverse proxy path
 proxy_pass http://192.168.8.107:8000;
 
 # Timeout for reverse proxy
 proxy_connect_timeout 10;
 
 }
 }

WordPress runs as a docker container on the 8000 port of the machine 192.168.8.107

The wordpress service in docker-compose wrote this (mysql is another container, don’t pay attention to this).

wordpress:
 image: wordpress
 container_name: wordpress
 restart: always
 ports:
 - 8000:80
 depends_on:
 - mysql
 environment:
 WORDPRESS_DB_PASSWORD: root
 WORDPRESS_DB_HOST: mysql:3306

However, the wordpress page cannot be accessed in this way. The 172.17.30.225 in the figure below is a springboard machine. If you don’t understand it, you can roughly understand it as the 192.168.8.107 machine.

图片描述

After accessing 172.17.30.225/wp, the address bar will automatically locate to /wp-admin/install.php, but the page cannot be displayed, as shown in the following figure.

图片描述

Normally this page is correct (please ignore this port number because this is a separate service).

图片描述

When requesting 192.168.8.107/wp, the address of the reverse proxy is 192.168.8.107:8000/wp, then WordPress is redirected to /wp-admin/install.php, and then nginx cannot find the corresponding location:/WP-admin
I haven’t used wordpress and I don’t know the url configuration. I can try to change the nginx location configuration to /wp-admin/