Skip to content

[Question] Serving fpm-alpine image with nginx #253

@lonix1

Description

@lonix1

I am trying to get the fpm-alpine image to work with nginx.

docker-compose.yml

version: "3.7"

networks:
  mynet:

volumes:
  mariadb_data:
  phpmyadmin_data:

services:

  mariadb:
    image: mariadb:10.4.8-bionic
    environment:
      MYSQL_DATABASE: mydb
      MYSQL_ROOT_PASSWORD: password
      MYSQL_USER: admin
      MYSQL_PASSWORD: password
    volumes:
      - mariadb_data:/var/lib/mysql/
    networks:
      - mynet

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:fpm-alpine
    volumes:
      - phpmyadmin_data:/var/www/html/
    networks:
      - mynet
    depends_on:
      - mariadb

  nginx:
    image: nginx:1.17.4-alpine
    volumes:
      - ./default.conf:/etc/nginx/conf.d/default.conf:ro
      - phpmyadmin_data:/var/www/html/:ro
    ports:
      - "80:80"
    networks:
      - mynet
    depends_on:
      - mariadb
      - phpmyadmin

default.conf

resolver 127.0.0.11 valid=15s;

server {

  listen 80;
  server_name www.example.com;

  root /var/www/html/;
  index index.php index.html index.htm;

  set $upstream phpmyadmin:9000;

  location ~ \/pma {
    fastcgi_pass $upstream;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
  }
}

Then: docker-compose up.

When I access http://www.example.com/pma I get

502 Bad Gateway

I also tried to get it working using a port instead of path, i.e. http://www.example.com:8080 instead of http://www.example.com/pma.

The docs show examples using traefik and haproxy, but not for nginx.

Can someone spot the error in my setup, or does someone have a working example to share?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions