[英]Incorrect URL on Wordpress using Docker
I've a pretty simple setup using Wordpress and Docker, with a docker-compose.yml
file: 我使用Wordpress和Docker通过
docker-compose.yml
文件进行了非常简单的设置:
wordpress:
depends_on:
db:
condition: service_healthy
restart: on-failure
image: wordpress:latest
volumes:
- ./backend/wordpress/wp-content:/var/www/html/wp-content
- ./backend/wordpress/.htaccess:/var/www/html/.htaccess
environment:
WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST}
WORDPRESS_DB_PASSWORD: ${MYSQL_ROOT_PASSWORD}
WORDPRESS_TABLE_PREFIX: ${WORDPRESS_TABLE_PREFIX}
WORDPRESS_CONFIG_EXTRA:
define('WP_ALLOW_REPAIR', true );
define('WP_HOME','${WORDPRESS_URL}:${NGINX_EXTERNAL_PORT}');
define('WP_SITEURL','${WORDPRESS_URL}:${NGINX_EXTERNAL_PORT}');
nginx:
build: ./backend/nginx
links:
- wordpress
- phpmyadmin
ports:
- ${NGINX_EXTERNAL_PORT}:80
volumes:
- "./backend/nginx/nginx.conf:/etc/nginx/nginx.conf"
And this is my nginx.conf
file: 这是我的
nginx.conf
文件:
upstream docker-wordpress {
server wordpress;
}
server {
listen 80;
server_name admin.example.com;
location / {
proxy_read_timeout 3600;
proxy_pass http://docker-wordpress;
}
}
Everything seems to work correctly till I try to sort my Wordpress posts by name or slug or whatever field you want, and not only when I sort but also when I try to go to a 2nd page. 直到我尝试按名称或子词或您想要的任何字段对Wordpress帖子进行排序之前,一切似乎都能正常运行,不仅是在排序时,而且在尝试进入第二页时。 Instead of getting something like:
而不是像这样:
http://admin.example.com:5000/wp-admin/edit.php?post_type=artista&orderby=title&order=asc
I get my upstream name on the links, like this: 我在链接上得到了上游名称,像这样:
http://docker-wordpress/wp-admin/edit.php?post_type=artista&orderby=title&order=asc
As I said, everything else works fine, and after taking a look at my site configuration I see that both Wordpress URL and Site URL are: 就像我说的,其他所有东西都可以正常工作,在查看了我的网站配置后,我发现Wordpress URL和Site URL都是:
http://admin.example.com:5000
Which I believe it's correct, any idea what could be wrong? 我认为这是正确的,知道有什么问题吗? Thanks!
谢谢!
最终有效的方法是将proxy_set_header
指令添加到我的nginx.conf
文件中:
proxy_set_header Host $http_host;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.