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

WP configuration #36

Closed Able2Code closed 5 years ago

Able2Code commented 5 years ago

By installing Wordpress and using ob_php-fpm container, i'm getting the mixed-content error over the entire site. How to correct this error? Thank you in advance !

Able2Code commented 5 years ago

Solved by editing wp-config.php define('FORCE_SSL_ADMIN', true); if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on'; but not i'm trowing "HTTP 502 / No backend servers found at the moment" after some plugins registration. How to solve this?

Able2Code commented 5 years ago

Hi @tspicer , how to prevent nginx to cache wordpress pages when i'm logged as administrator? i'm using the php configuration with redis, in many cases when i visit any site page, the cache save also the wp admin toolbar header , by visiting in incognito i can see the cached wp admin toolbar. I see also you wordpress dedicated git, this config will fix my problem? can i use you installer in any vps ?

wualex commented 5 years ago

@Able2Code how did you solve the 502 issue? have the same problem

tspicer commented 5 years ago

Since this is an NGINX (not Wordpress) repo, I will do my best to assist.

It is hard to troubleshoot these errors given the variations of configs. I'm happy to help, but please post configs for NGINX and wordpress. For example, in NGINX you can set it to not cache anything /wp-admin*. Also, if you have a WP installer you are using, please share that as well.

wualex commented 5 years ago

This would be my docker compose file

`version: '3'

services: web: depends_on:

docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 44468c130c9b openbridge/nginx "/docker-entrypoint.…" 3 days ago Up 3 days *:80->80/tcp, *:443->443/tcp rec_web_1 c0cb54a5774a wordpress:php7.3-fpm-alpine "docker-entrypoint.s…" 3 days ago Up 3 days 9000/tcp rec_wp_1 ab84677495fb mysql:5.7 "docker-entrypoint.s…" 3 days ago Up 3 days 3306/tcp, 33060/tcp rec_db_1 4257ef159d62 redis:alpine "docker-entrypoint.s…" 3 days ago Up 3 days 6379/tcp redis

But when i try to access somedomain.tld i get "HTTP 502 / No backend servers found at the moment"

tspicer commented 5 years ago

Hi, I noticed you set your PROXY address to your PHP service. Is there a reason you are directing NGINX to connect to PHP as a PROXY? You have NGINX_PROXY_UPSTREAM: wp:9000. I would normally expect a reverse proxy to be internal, so something like NGINX_PROXY_UPSTREAM=localhost:8080

The docs dig into this: https://github.com/openbridge/nginx#digging-into-the-env-file

Take a look at where this setting is used: https://github.com/openbridge/nginx/tree/master/conf/php/nginx/upstream.d

In a nutshell, it appears you are treating the proxy and php-fpm as the same thing. Maybe this is a typo?

I can envision certain configurations where the PROXY is a different connection, but this is an advanced setup. Also, you may want to try using this container for PHP-FPM: https://github.com/openbridge/ob_php-fpm

It affords more flexibility and is optimized for this WP.

tspicer commented 5 years ago

In nginx.conf notice the upstream includes are distinct for each service. If PHP and PROXY are the same, I'm not sure how it would work properly.

upstream php-fpm      {include /etc/nginx/upstream.d/php-fpm.conf;}
upstream proxy      {include /etc/nginx/upstream.d/proxy.conf;}
upstream redis     {include /etc/nginx/upstream.d/redis.conf;}
wualex commented 5 years ago

@tspicer changed NGINX_PROXY_UPSTREAM to localhost:8080 and that made it work i can't wrap my head around it at the moment but i'll read some more docs to understand how it really works

thank you!

tspicer commented 5 years ago

awesome, glad to hear.