0

I've these two containers:

  nginx:
    image: nginx:1.17.4-alpine
    container_name: nginx
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - './certs:/etc/nginx/certs'
      - './site.conf:/etc/nginx/conf.d/site.conf'
  pma:
    image: phpmyadmin/phpmyadmin:4.9-fpm
    container_name: pma
    environment:
      - PMA_ARBITRARY=1
      - 'PMA_ABSOLUTE_URI=https://pma.local/'

In site.conf, how can I "pass" requests to PhpMyAdmin on port 9000? I've tried:

server {
    listen 443 ssl;
    server_name pma.local;
    ssl_certificate /etc/nginx/certs/pma.local.crt;
    ssl_certificate_key /etc/nginx/certs/pma.local.key;

    location / {
        proxy_pass https://pma.local:9000;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

But this is clearly not working...could you please point me in the right direction? Thanks.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Jumpa
  • 4,319
  • 11
  • 52
  • 100
  • 2
    What is the error you are getting, is it nginx error or the app itself not working or is it docker error? can help in pointing out the issue – ROOT Jan 18 '20 at 19:13
  • You might want to ask this on [Server Fault](//serverfault.com) as this is more about configuring nginx – Machavity Jan 18 '20 at 19:25

1 Answers1

0

When using docker-compose it automatically creates a network for all containers so they can communicate with each other. Each container can be resolved using it's name in the docker-compose file, the following names are used in your file: nginx and pma.

This means pma should be used when searching for the fpm(fastcgi_pass):

 location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass pma:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
MaartenDev
  • 5,631
  • 5
  • 21
  • 33