PrestaShop / PrestaShop/docker

Prestashop 8.1 FPM with Nginx - 504 Gateway Timeout

Open
#352 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dockerfile
Stars
281
Forks
190
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am trying to get Prestashop 8.1 running on Docker as my dev environment, but I can't succeed. First I tried the prestashop:latest image with Apache web server and used Nginx as a SSL Proxy to run it over HTTPS. Everything worked fine until the Theme Installation step in the installer; I was getting 504 Gateway Time-out error. Running it just on Apache without Nginx didn't helped. Tried setting the proxy timeout limits to a higher value, still no luck.

I've decided to use FPM image instead. Now the Prestashop's docker log says that the FPM is listening for connections, my nginx server seems to be configured correctly, everything's up, but I get the 502 Bad Gateway error trying to open the installer via localhost in my browser...

Can someone help me with this one?

Docker log:

prestashop                       | [10-Aug-2023 02:44:23] NOTICE: fpm is running, pid 1

prestashop                       | [10-Aug-2023 02:44:23] NOTICE: ready to handle connections
 
shop-nginx-proxy-1  | 2023/08/10 02:46:31 [error] 29#29: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: localhost, request: "GET / HTTP/2.0", upstream: "http://172.18.0.3:80/", host: "localhost"

shop-nginx-proxy-1  | 172.18.0.1 - - [10/Aug/2023:02:46:31 +0000] "GET / HTTP/2.0" 502 559 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" "-"

shop-nginx-proxy-1  | 2023/08/10 02:46:31 [error] 29#29: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: localhost, request: "GET /favicon.ico HTTP/2.0", upstream: "http://172.18.0.3:80/favicon.ico", host: "localhost", referrer: "https://localhost/"

shop-nginx-proxy-1  | 172.18.0.1 - - [10/Aug/2023:02:46:31 +0000] "GET /favicon.ico HTTP/2.0" 502 559 "https://localhost/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" "-"

My docker-compose.yml:
I have all my .env values in correctly. "PS_DOMAIN" is set to "localhost".

version: '3'
services:

  nginx-proxy:  # Nginx web server
    image: nginx:latest  # Latest Nginx Server Image
    depends_on:
      - prestashop
    ports:
      - 80:80
      - 443:443
    networks:
      - prestashop_network
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf  # Mount the Nginx config
      - ./ssl:/etc/nginx/ssl  # Mount the SSL folder to provide certs

  mysql:  # MySQL DB
    container_name: mysql
    image: mysql:latest  # Latest MySQL Server Image
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWD}  # MySQL Root Password
      MYSQL_DATABASE: ${MYSQL_DATABASE}  # Project's database
      MYSQL_USER: ${MYSQL_USER}  # Project's database user
      MYSQL_PASSWORD: ${MYSQL_USER_PASSWD}  # Project's database password
    ports:
      - 3306:3306
    networks:
      - prestashop_network
    volumes:
      - mysql-data:/var/lib/mysql  # Mount the MySQL data volume

  prestashop:  # Prestashop Shop CMS
    container_name: prestashop
    # image: prestashop/prestashop:latest  # Latest Prestashop Apache Image
    image: prestashop/prestashop:8.1.1-8.1-fpm  # FPM Nginx Prestashop Image
    restart: unless-stopped
    depends_on:
      - mysql
    environment:
      PS_DEV_MODE: ${PS_DEV_MODE} # Development mode
      PS_INSTALL_AUTO: ${PS_INSTALL_AUTO}  # Install Prestashop automatically
      PS_INSTALL_DB: ${PS_INSTALL_DB}  # Create DB on install
      PS_ERASE_DB: ${PS_ERASE_DB}  # Erase DB on install
      PS_ENABLE_SSL: ${PS_ENABLE_SSL}  # Enable SSL on install
      PS_DOMAIN: ${PS_DOMAIN}  # Domain for Prestashop installation
      DB_SERVER: ${PS_DATABASE_SERVER}  # Project's database server
      DB_NAME: ${PS_DATABASE}  # Project's database
      DB_USER: ${PS_DATABASE_USER}  # Project's database user
      DB_PASSWD: ${PS_DATABASE_PASSWD}  # Project's database password
      ADMIN_MAIL: ${PS_ADMIN_MAIL}  # Prestashop admin email
      ADMIN_PASSWD: ${PS_ADMIN_PASSWD}  # Prestashop admin password
      PS_FOLDER_ADMIN: ${PS_FOLDER_ADMIN}  # Prestashop admin folder/url
    networks:
      - prestashop_network
    volumes:
      - ./src:/var/www/html  # Mount the local src directory to the container

networks:
  prestashop_network:  # Define a shared network for this setup

volumes:
  mysql-data:  # Define the MySQL data volume

nginx.conf:

server {
   server_name localhost;

   location / {
       return 301 https://$host$request_uri;
   }
}

server {
   listen 443 ssl;
   http2 on;
   server_name localhost;

   ssl_protocols TLSv1.2 TLSv1.3;
   ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
   ssl_prefer_server_ciphers off;

   ssl_session_timeout 1d;
   ssl_session_cache shared:MozSSL:10m;
   ssl_session_tickets off;

   ssl_certificate /etc/nginx/ssl/server.crt;
   ssl_certificate_key /etc/nginx/ssl/server.key;

   proxy_connect_timeout 600s;
   proxy_send_timeout 600s;
   proxy_read_timeout 600s;


   location / {
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Host $http_host;
       proxy_set_header X-Forwarded-Proto $scheme;

       proxy_pass http://prestashop;
   }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the docker-compose.yml and nginx.conf shown in the report, then inspect the PrestaShop and Nginx container logs while requesting localhost. Compare the FPM service and proxy configuration with the image's documented entry points. Done means the installer loads through HTTPS without the reported 502 or 504 errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, mysql, nginx, php
Domain
backend, devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.