Reputation: 378
I've a pretty simple setup using Wordpress and Docker, with a docker-compose.yml
file:
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:
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. 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:
http://admin.example.com:5000
Which I believe it's correct, any idea what could be wrong? Thanks!
Upvotes: 0
Views: 3678
Reputation: 378
What worked finally was to adding a proxy_set_header
directive to my nginx.conf
file:
proxy_set_header Host $http_host;
Upvotes: 3