openbridge / nginx

NGINX Accelerated! This is a Docker image that creates a high performance (FAST!), optimized image for NGINX for use with Redis and PHP-FMP. Deliver sites and applications with performance, reliability, security, and scale. This NGINX server offers advanced performance, web and mobile acceleration, security controls, application monitoring, and management.
https://www.openbridge.com/
MIT License
233 stars 53 forks source link

502 Bad Gateway (ob_php-fpm/wordpress) #42

Closed lamariabdo closed 5 years ago

lamariabdo commented 5 years ago

502 Bad Gateway when run openbridge/nginx with mariadb and wordpress-fpm or ob_php-fpm

Hello, please i always get 502 bad gateway when run openbridge/nginx with mariadb & wordpress or only with ob_php-fpm like some issus with nginx and php-fpm connection

Please how i can solve this issue, i would appreciate your help. My docker-compose.yml , env file and logs are bellow

Error 502 Bad Gateway nginx

Config Env: local Os: Windows 10 pro Docker version: 2.0.0.3 (31259) (Channel: stable -Build: 8858db3

Env file nginx.env: NGINX_SERVER_NAME=localhost NGINX_APP_PLUGIN= NGINX_CONFIG=php NGINX_DEV_INSTALL=true PHP_FPM_UPSTREAM=localhost:9000 REDIS_UPSTREAM=redis:6379 NGINX_PROXY_UPSTREAM=localhost:8080 NGINX_DOCROOT=/var/www/html

docker-compose.yml `version: '3.3'

services:

nginx: image: openbridge/nginx container_name: nginx depends_on:

Logs redis 1:C 02 Jun 2019 22:33:31.866 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 1:C 02 Jun 2019 22:33:31.866 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=1, just started 1:C 02 Jun 2019 22:33:31.866 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf 1:M 02 Jun 2019 22:33:31.867 * Running mode=standalone, port=6379. 1:M 02 Jun 2019 22:33:31.867 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 1:M 02 Jun 2019 22:33:31.867 # Server initialized 1:M 02 Jun 2019 22:33:31.867 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 1:M 02 Jun 2019 22:33:31.867 * Ready to accept connections

mariadb 2019-06-02 22:33:33 0 [Note] mysqld (mysqld 10.3.15-MariaDB-1:10.3.15+maria~bionic) starting as process 1 ... 2019-06-02 22:33:33 0 [Note] InnoDB: Using Linux native AIO 2019-06-02 22:33:33 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2019-06-02 22:33:33 0 [Note] InnoDB: Uses event mutexes 2019-06-02 22:33:33 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2019-06-02 22:33:33 0 [Note] InnoDB: Number of pools: 1 2019-06-02 22:33:33 0 [Note] InnoDB: Using SSE2 crc32 instructions 2019-06-02 22:33:33 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M 2019-06-02 22:33:33 0 [Note] InnoDB: Completed initialization of buffer pool 2019-06-02 22:33:33 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2019-06-02 22:33:33 0 [Note] InnoDB: 128 out of 128 rollback segments are active. 2019-06-02 22:33:33 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2019-06-02 22:33:33 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2019-06-02 22:33:33 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2019-06-02 22:33:33 0 [Note] InnoDB: Waiting for purge to start 2019-06-02 22:33:33 0 [Note] InnoDB: 10.3.15 started; log sequence number 1630842; transaction id 21 2019-06-02 22:33:33 0 [Note] Plugin 'FEEDBACK' is disabled. 2019-06-02 22:33:33 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2019-06-02 22:33:33 0 [Note] InnoDB: Buffer pool(s) load completed at 190602 22:33:33 2019-06-02 22:33:33 0 [Note] Server socket created on IP: '::'. 2019-06-02 22:33:33 0 [Warning] 'proxies_priv' entry '@% root@4f1332f8fd18' ignored in --skip-name-resolve mode. 2019-06-02 22:33:33 0 [Note] Reading of all Master_info entries succeded 2019-06-02 22:33:33 0 [Note] Added new Master_info '' to hash table 2019-06-02 22:33:33 0 [Note] mysqld: ready for connections. Version: '10.3.15-MariaDB-1:10.3.15+maria~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution

nginx { "@timestamp": "2019-06-02T22:40:37+00:00", "@fields": { "remote_addr": "172.23.0.1", "remote_user": "-", "status": "502", "request": "GET / HTTP/2.0", "request_uri": "/", "request_method": "GET", "request_time": "0.000", "request_uri_query": "-", "http_referrer": "-", "http_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36", "http_forward": "172.23.0.1", "http_header": "-", "body_bytes_sent": "552", "geo_country": "-", "geo_city": "-", "server_name": "localhost", "upstream_addr": "127.0.0.1:8080", "upstream_status": "502", "upstream_response_time": "0.000", "upstream_response_length": "552", "upstream_cache_status": "BYPASS" } } 2019/06/02 22:40:37 [error] 1041#1041: *92 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost" { "@timestamp": "2019-06-02T22:40:37+00:00", "@fields": { "remote_addr": "127.0.0.1", "remote_user": "-", "status": "502", "request": "GET / HTTP/1.1", "request_uri": "/", "request_method": "GET", "request_time": "0.000", "request_uri_query": "-", "http_referrer": "-", "http_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36", "http_forward": "172.23.0.1, 127.0.0.1", "http_header": "-", "body_bytes_sent": "552", "geo_country": "-", "geo_city": "-", "server_name": "localhost", "upstream_addr": "127.0.0.1:9000", "upstream_status": "502", "upstream_response_time": "0.000", "upstream_response_length": "0", "upstream_cache_status": "MISS" } } { "@timestamp": "2019-06-02T22:40:37+00:00", "@fields": { "remote_addr": "172.23.0.1", "remote_user": "-", "status": "502", "request": "GET / HTTP/2.0", "request_uri": "/", "request_method": "GET", "request_time": "0.000", "request_uri_query": "-", "http_referrer": "-", "http_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36", "http_forward": "172.23.0.1", "http_header": "-", "body_bytes_sent": "552", "geo_country": "-", "geo_city": "-", "server_name": "localhost", "upstream_addr": "127.0.0.1:8080", "upstream_status": "502", "upstream_response_time": "0.000", "upstream_response_length": "552", "upstream_cache_status": "BYPASS" } }

wordpress '[02-Jun-2019 22:33:33 UTC] PHP Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22

MySQL Connection Error: (2002) Connection refused [02-Jun-2019 22:33:36] NOTICE: fpm is running, pid 1 [02-Jun-2019 22:33:36] NOTICE: ready to handle connections'

tspicer commented 5 years ago

Where is your PHP container in docker compose? The wordpress one? I have not tested that service so I can't really comment on the correct configuration. However, something seems wrong with that. It looks like a connection to MySQL can't be made from that service. No ports for wp? You specify PHP_FPM_UPSTREAM=localhost:9000 yet I see nothing running on that port

tspicer commented 5 years ago

Did you look at https://github.com/openbridge/ob_php-fpm/blob/master/wordpress.yml for reference?

lamariabdo commented 5 years ago

Thank you for your answer,i fixed the problem i changed PHP_FPM_UPSTREAM=wordpress:9000

and i added this command to mariadb command: 'mysqld --innodb-flush-method=fsync'

now it's work perfectly