我正在尝试在/blog
路径上使用docker-compose和nginx设置wordpress。我已经成功进行了设置,当我连接到http://localhost/blog/wp-login.php
时,我被重定向到http://localhost/blog//wp-admin/
。现在,无论我在页面上单击什么位置,都将重定向回登录页面。我在nginx.conf
中尝试了不同的组合,但无济于事。
我的docker-compose.yml
version: '2'
services:
db_wordpress:
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_wordpress
image: wordpress:latest
volumes:
- ./wordpress:/var/www/html
restart: always
expose:
- 80
environment:
WORDPRESS_DB_HOST: db_wordpress:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DEBUG: 1
WORDPRESS_CONFIG_EXTRA: |
define('WP_HOME','http://localhost/blog');
define('WP_SITEURL','http://localhost/blog');
$$_SERVER['REQUEST_URI'] = '/blog' . $$_SERVER['REQUEST_URI'];
nginx:
image: nginx
restart: always
ports:
- "80:80"
- "443:443"
links:
- wordpress
volumes:
- ./logs/nginx:/var/log/nginx
- ./nginx.local.conf:/etc/nginx/nginx.conf
volumes:
db_data:
还有我的nginx.conf
events {
worker_connections 1024;
}
http {
upstream wordpress {
server wordpress:80;
}
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server_names_hash_bucket_size 512;
server {
listen 80;
server_name _;
location /blog {
proxy_pass http://wordpress/;
proxy_buffering off;
proxy_redirect off;
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;
}
}
}