502 error with wordpress:fpm
See original GitHub issueTL;DR why this wordpress:latest Dockerfile is ok with
nginx-proxy
but this one not wordpress:fpm Dockerfile ? And how can I use awordpress:fpm
image withnginx-proxy
Hi,
I successfully use nginx-proxy with some wordpress container. for example this docker-compose.yml
works perfectly :
db:
image: mariadb
environment:
- MYSQL_ROOT_PASSWORD=password
volumes:
- /home/stack/my_domain/bdd:/var/lib/mysql
wordpress:
image: wordpress
links:
- db:mysql
environment:
- VIRTUAL_HOST=my_domain.fr,www.my_domain.fr
- LETSENCRYPT_HOST=www.my_domain.fr
- LETSENCRYPT_EMAIL=contact@my_domain.fr
env_file:
- ./env
volumes:
- /home/stack/my_domain/wordpress:/var/www/html
BUT if I use the wordpress:fpm
image (instead of an apache based image) I have 502 Bad Gateway error, and this message in the log:
nginx.1 | 2017/08/14 21:29:51 [error] 347#347: *2447 connect() failed (111: Connection refused) while connecting to upstream, client: 86.222.20.31, server: www.my_domain.fr, request: “GET /contact/ HTTP/2.0”, upstream: “http://172.17.0.14:80/contact/”, host: “www.my_domain.fr”, referrer: “https://www.my_domain.fr/”
and this message :
root@9408854fae4b:/etc/nginx/conf.d# nginx -s reload 2017/08/14 21:37:35 [emerg] 671#671: invalid number of arguments in “upstream” directive in /etc/nginx/conf.d/default.conf:53 nginx: [emerg] invalid number of arguments in “upstream” directive in /etc/nginx/conf.d/default.conf:53
the default.conf at line 53 contains
upstream mydomain.fr {
## Can be connect with "bridge" network
# my_domain_wordpress_1
server 172.17.0.14:9000;
}
other domain have server 172.17.0.xx:80;
so I add port:80
and/or expose:80
in the docker-compose.yml file. I manage to obtain
upstream mydomain.fr {
## Can be connect with "bridge" network
# my_domain_wordpress_1
server 172.17.0.14:80;
}
but with the same 502 error.
Any idea why ?
Regards
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Did you finally found a solution for that? I used the alpine image of nginx-proxy,
VIRTUAL_PROTO: fastcgi VIRTUAL_ROOT: /usr/src/wordpress With no success: I get a 404 error message. When I go to url: http://mysite/index.php, I get several lines like this one:
wordpress_1 | [27-May-2018 06:57:39] WARNING: [pool www] child 58 said into stderr: "NOTICE: Access to the script '/usr/src/wordpress/wp-includes/css/buttons.min.css' has been denied (see security.limit_extensions)"
nginx-proxy already has support for fastcgi. Just add VIRTUAL_PROTO: fastcgi to your container environment variables. But you would also have to provide custom config for wordpress. Apache version has .htaccess with rewrites, but when you use nginx it should handle rewrites. Something like this described in official docs here: https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/