question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

502 error with wordpress:fpm

See original GitHub issue

TL;DR why this wordpress:latest Dockerfile is ok with nginx-proxy but this one not wordpress:fpm Dockerfile ? And how can I use a wordpress:fpm image with nginx-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:open
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
KZARCAcommented, May 27, 2018

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)"

0reactions
stepanordacommented, Jul 15, 2020

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/

Read more comments on GitHub >

github_iconTop Results From Across the Web

NGINX 502 Bad Gateway: PHP-FPM - Datadog
NGINX will return a 502 Bad Gateway error if it can't successfully proxy a request to PHP-FPM, or if PHP-FPM fails to respond....
Read more >
502 Server Error | WordPress.org
An HTTP 502 error is a bad gateway. It may be Nginx saying that PHP-FPM is not responding in a timely manner. If...
Read more >
Why Am I Seeing NGINX 502 Bad Gateway: PHP-FPM?
502 Bad Gateway means that the server you are accessing receives an error from another server. This happens when one server acts as...
Read more >
502 error with wordpress:fpm · Issue #905 - GitHub
BUT if I use the wordpress:fpm image (instead of an apache based image) I have 502 Bad Gateway error, and this message in...
Read more >
502 Bad Gateway Error and How to Fix It - 10Web
In your WordPress website with Nginx/PHP-FPM stack, a 502 error can happen when PHP-FPM is not running or Nginx can't communicate with PHP-FPM...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found