docker - 502 error with wordpress:fpm using jwilder/nginx-proxy -


tl;dr why wordpress:latest dockerfile ok nginx-proxy 1 not wordpress:fpm dockerfile ? , how can use wordpress:fpm image nginx-proxy

hi,

i use nginx-proxy wordpress container. example docker-compose.yml works :

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 use wordpress:fpm image (instead of apache based image) have 502 bad gateway error, , message in log:

nginx.1 | 2017/08/14 21:29:51 [error] 347#347: *2447 connect() failed (111: connection refused) while connecting 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 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 @ line 53 contains

upstream mydomain.fr {                                 ## can connect "bridge" network                         # my_domain_wordpress_1                         server 172.17.0.14:9000; } 

other domain have server 172.17.0.xx:80; add port:80 and/or expose:80 in docker-compose.yml file. manage obtain

upstream mydomain.fr {                                 ## can connect "bridge" network                         # my_domain_wordpress_1                         server 172.17.0.14:80; } 

but same 502 error.

any idea why ?

regards

the reason both of images different in working.

the wordpress:latest uses apache on port 80 , responds requests proper php script executed. handles http protocol.

on other hand wordpress:fpm uses php-fpm, fast cgi server, not expecting proxy_pass other nginx parameters below

     location ~ \.php$ {      try_files $uri =404;            fastcgi_pass http://fpm:9000;            fastcgi_index index.php;            include /etc/nginx/fastcgi_params;      } 

nginx-proxy image checks containers launched virtual_host environment variables, check exposed ports , creates proxy pass template. need different template this. can done using per-host configuration.

per-virtual_host

to add settings on per-virtual_host basis, add configuration file under /etc/nginx/vhost.d. unlike in proxy-wide case, allows multiple config files name ending in .conf, per-virtual_host file must named after virtual_host.

in order allow virtual hosts dynamically configured backends added , removed, makes sense mount external directory /etc/nginx/vhost.d opposed using derived images or mounting individual configuration files.

for example, if have virtual host named app.example.com, provide custom configuration host follows:

$ docker run -d -p 80:80 -p 443:443 -v /path/to/vhost.d:/etc/nginx/vhost.d:ro -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy $ { echo 'server_tokens off;'; echo 'client_max_body_size 100m;'; } > /path/to/vhost.d/app.example.com

follow below url more details

https://github.com/jwilder/nginx-proxy#per-virtual_host


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -