Nginx Proxy Manager with Magento 2 and Docker Compose

Viewed 279

I am trying to get Magento 2 working inside of a docker compose file with Portainer and Nginx Proxy Manager.

I am using the bitnami docker containers.

I keep getting 502 Bad Gateway error

Here is my docker-compose.yaml

version: '2'
services:
  mariadb:
    image: docker.io/bitnami/mariadb:10.3
    environment:
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=bn_magento
      - MARIADB_DATABASE=bitnami_magento
    volumes:
      - 'mariadb_data:/bitnami/mariadb'
    networks:
      - magento-network
  magento:
    image: docker.io/bitnami/magento:2
    environment:
      - MAGENTO_HOST=mywebsite.com //is set to my domain, unsure if I should add https though
      - MAGENTO_DATABASE_HOST=mariadb
      - MAGENTO_DATABASE_PORT_NUMBER=3306
      - MAGENTO_DATABASE_USER=bn_magento
      - MAGENTO_DATABASE_NAME=bitnami_magento
      - ELASTICSEARCH_HOST=elasticsearch
      - ELASTICSEARCH_PORT_NUMBER=9200      
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - 'magento_data:/bitnami/magento'
    depends_on:
      - mariadb
      - elasticsearch
    networks:
      - magento-network
      - reverseproxy-nw
  elasticsearch:
    image: docker.io/bitnami/elasticsearch:7
    volumes:
      - 'elasticsearch_data:/bitnami/elasticsearch/data'
    networks:
      - magento-network
volumes:
  mariadb_data:
  magento_data:
  elasticsearch_data:
networks:
  magento-network:
  reverseproxy-nw:
    external: true

In Nginx Proxy Manager I have

scheme   forward hostname  port
http    magento_magento_1  8080

With SSL force SSL on.

In the container logs for magento I can see:

[12/Jan/2022:21:38:38 +0000] "GET /favicon.ico HTTP/1.1" 302 -
[12/Jan/2022:21:40:06 +0000] "GET / HTTP/1.1" 302 -
1 Answers

I installed the magento2 when I am trying to open some pages facing 502 Nginx issue,

in Nginx logs, it is showing

upstream sent too big header while reading response header from upstream,

then solved this issue by modifying this file

/etc/nginx/nginx.conf

add this line of codes inside http{}

fastcgi_buffers 16 16k;

fastcgi_buffer_size 32k;

proxy_buffer_size 128k;

proxy_buffers 4 256k;

proxy_busy_buffers_size 256k;

for more details refer below link

https://bobcares.com/blog/magento-502-bad-gateway/?unapproved=75360&moderation-hash=21aca5cefbcdd86f62c492697cb64954#comment-75360

Related