Giter VIP home page Giter VIP logo

Comments (9)

thilak-rao avatar thilak-rao commented on August 25, 2024

Setting these variables fixed my previous issue:

ENV PHP_FPM_UPSTREAM="wordpress:9000"
ENV NGINX_PROXY_UPSTREAM="wordpress:9000"
ENV REDIS_UPSTREAM="redis:6379

but now when I run curl https://localhost --insecure, I get this instead of wordpress:

    <html><head><meta http-equiv="refresh" content="1">
    </head><body><br/><br/><h1>HTTP 502 / No backend servers found at the moment</h1>
    <h3>Refreshing automatically to reconnect to backend...</h3></body>

from nginx.

tspicer avatar tspicer commented on August 25, 2024

Normally a 502 error will occur because of different startup times between your instances. In this case, it is likely PHP and Wordpress were not available for Nginx to connect. It might take 20-30 seconds.

from nginx.

thilak-rao avatar thilak-rao commented on August 25, 2024

That's unlikely. Here's the output of docker ps:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                      NAMES
509706a826b3        proxy_nginx         "/docker-entrypoint.…"   6 minutes ago       Up 6 minutes        0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   nginx
492bb39a3bc2        mysql:5.7           "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        3306/tcp, 33060/tcp                        mysql
c9e4aa077510        redis:alpine        "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        6379/tcp                                   redis
2d9ed52a0572        wordpress:php7.1-fpm-alpine      "docker-entrypoint.s…"   About an hour ago   Up About an hour    9000/tcp                                   wordpress

Thanks for taking the time to open source this image! It's a great starting point with good defaults. 🍻

from nginx.

tspicer avatar tspicer commented on August 25, 2024

can you do docker logs for the wordpress container? Would be curious what it says. Also, can you share your docker compose yml?

from nginx.

thilak-rao avatar thilak-rao commented on August 25, 2024

First Dockerfile:

FROM wordpress:php7.1-fpm-alpine
RUN mkdir -p /var/www/html/wp-content/themes/demo/
COPY . /var/www/html/wp-content/themes/demo/

First docker-compose.yml:

version: '3.7'

services:
  wordpress:
    build: .
    container_name: wordpress
    restart: unless-stopped
    volumes:
      - thilak_root:/var/www/html
    networks:
      - proxy
    environment:
      WORDPRESS_DB_HOST: mysql
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_PASSWORD: 'super_secret'

networks:
  proxy:
    external: true

volumes:
  wordpress_root:
    external: true

Second Dockerfile:

FROM openbridge/nginx:latest
ENV NGINX_CONFIG=php
ENV NGINX_DEV_INSTALL=true
ENV PHP_FPM_UPSTREAM="wordpress:9000"
ENV NGINX_PROXY_UPSTREAM="wordpress:9000"
ENV REDIS_UPSTREAM="redis:6379"
ENV NGINX_SERVER_NAME=localhost

Second docker-compose.yml:

version: '3.7'

services:
  nginx:
    build: .
    restart: unless-stopped
    container_name: nginx
    ulimits:
      nproc: 65535
      nofile:
        soft: 49999
        hard: 99999
    tmpfs: /var/cache
    tty: true
    volumes:
      - type: volume
        source: wordpress_root
        target: /usr/share/nginx/html
        volume:
          nocopy: true
    logging:
      driver: "json-file"
      options:
        max-size: "1k"
        max-file: "3"
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443

  mysql:
    image: mysql:5.7
    container_name: mysql
    restart: unless-stopped
    networks:
      - proxy
    environment:
      MYSQL_ROOT_PASSWORD: 'super_secret'
    volumes:
      - mysql:/var/lib/mysql

  redis:
    image: redis:alpine
    container_name: redis
    networks:
      - proxy
    restart: unless-stopped

networks:
  proxy:
    external: true

volumes:
  wordpress_root:
    external: true
  mysql:
    external: true

Output of docker logs of WordPress container

WordPress not found in /var/www/html - copying now...
WARNING: /var/www/html is not empty! (copying anyhow)
Complete! WordPress has been successfully copied to /var/www/html
[28-Jan-2019 18:27:59] NOTICE: fpm is running, pid 1
[28-Jan-2019 18:27:59] NOTICE: ready to handle connections

from nginx.

tspicer avatar tspicer commented on August 25, 2024

I don't see your wordpress container in the compose file. I don't think it is going to understand wordpress:9000 as a reference if you are not doing this.

from nginx.

thilak-rao avatar thilak-rao commented on August 25, 2024

Are you sure about that? My previous setup involved wordpress/php7.1-apache with nginx:latest on the front and I was able to proxy wordpress:80 just fine, and WordPress container was able to connect with MySQL.

My understanding was containers that share the same network (proxy in my case) can talk to one another.

from nginx.

thilak-rao avatar thilak-rao commented on August 25, 2024

@tspicer To test your hypothesis, I moved wordpress:php7.1-fpm-alpine image into the docker compose file, but I still have the same issue

curl https://localhost --insecure

# Output: 
    <html><head><meta http-equiv="refresh" content="1">
    </head><body><br/><br/><h1>HTTP 502 / No backend servers found at the moment</h1>
    <h3>Refreshing automatically to reconnect to backend...</h3></body>

You can clone this repo and run start.sh (this shell script creates the external volumes).

from nginx.

thilak-rao avatar thilak-rao commented on August 25, 2024

When I SSH into the docker openbridge/nginx:latest container, I'm able to ping wordpress hostname successfully.

from nginx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.