phpmyadmin / docker

Docker container for phpMyAdmin
https://hub.docker.com/_/phpmyadmin
GNU General Public License v3.0
671 stars 456 forks source link

fpm-alpine + haproxy #327

Closed qeepcologne closed 3 years ago

qeepcologne commented 3 years ago

i'm trying to switch from pma to pma-fpm-alpine

haproxy.cfg (following https://www.haproxy.com/de/blog/load-balancing-php-fpm-with-haproxy-and-fastcgi/)

backend pma
  mode http
  server pma 10.10.10.200:80 maxconn 20 verify none check`

=>

backend pmafpm
  use-fcgi-app php-fpm
  server pma 10.10.10.209:9000 proto fcgi

fcgi-app php-fpm
  log-stderr global
  docroot /var/www/html
  index index.php
  path-info ^(/.+\.php)(/.*)?$

docker-compose.yml

version: '3.8'
services:
  phpmyadmin:
    container_name: pmafpm
    image: phpmyadmin/phpmyadmin:5.1.0-fpm-alpine
    environment:
      - PMA_HOST=users_db
      - PMA_ABSOLUTE_URI=https://pma-staging.qeep.net
      - PMA_USER=removed
      - PMA_PASSWORD=removed
    networks:
      mynet:
        ipv4_address: 10.10.10.209
    volumes:
     - /sessions
     - ./phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
    restart: unless-stopped
networks:
     mynet:
        external:
          name: haproxy_mynet

first problem: had to edit /usr/local/etc/php-fpm.d/www.conf and add .js .css .png .gif .ico .map to security.limit_extensions

second problem: unusable slow could be improved by increasing pm.max_children and pm.max_spare_servers

the result is starting up, but css still looks missing/broken, it's still very slow and there is some error output

Notice in ./libraries/classes/Controllers/HomeController.php#177
 Undefined index: SERVER_SOFTWARE

Backtrace

./libraries/classes/Routing.php#186: PhpMyAdmin\Controllers\HomeController->index(array)
./index.php#18: PhpMyAdmin\Routing::callControllerForRoute(
string '/',
,

Is anybody using current fpm-alpine?

williamdes commented 3 years ago

Hi @qeepcologne Sorry for the delay, I could also reproduce the issue you reported Undefined index: SERVER_SOFTWARE

But here is my actual config, static files should not pass in the CGI, I did not find how until now.

Source: https://www.haproxy.com/fr/blog/load-balancing-php-fpm-with-haproxy-and-fastcgi/

global
    daemon
    log 127.0.0.1 local0 debug
    user haproxy
    group haproxy

defaults
  log global
  mode http
  option  httplog
  option  dontlognull
  option http-server-close
  timeout connect 5000
  timeout client  50000
  timeout server  50000

frontend myproxy
    log global
    bind :80
    default_backend phpservers

backend phpservers
    use-fcgi-app php-fpm
    server server1 7.4-lowmem.williamdes.local:9000 proto fcgi

fcgi-app php-fpm
    log-stderr global
    docroot /home/www/phpMyAdmin
    index index.php
    path-info ^(/.+\.php)(/.*)?$
williamdes commented 3 years ago

Here is my final working version:

global
    daemon
    log 127.0.0.1 local0 debug
    user haproxy
    group haproxy

defaults
  log global
  mode http
  option  httplog
  option  dontlognull
  option http-server-close

frontend myproxy
    log global
    bind :80
    default_backend phpservers
    acl js_vendors_folder url_reg /js/
    acl themes_foler url_reg /themes/

    use_backend nginx_content if js_vendors_folder
    use_backend nginx_content if themes_foler

backend nginx_content
    option httpchk GET /.nginx/status
    http-check expect status 200
    default-server inter 30s fastinter 1s downinter 1s
    server webdav 7.4-lowmem.williamdes.local:80 check

backend phpservers
    use-fcgi-app php-fpm
    server server1 7.4-lowmem.williamdes.local:9000 proto fcgi

fcgi-app php-fpm
    log-stderr global
    docroot /home/www/phpMyAdmin
    index index.php
    path-info ^(/.+\.php)(/.*)?$

And the error you reported will be fixed in: https://github.com/phpmyadmin/phpmyadmin/issues/16854

qeepcologne commented 3 years ago

thanks a lot, i will test it again, when the bug is fixed.

williamdes commented 3 years ago

thanks a lot, i will test it again, when the bug is fixed.

I think you can try the latest 5.1 version in development (phpMyAdmin 5.1+snapshot). The fix should be included

qeepcologne commented 3 years ago

sorry this config with 2 different backends is pain, i also need a long backend acl selection based on subdomain and ip filter http-request deny inside the backend. There is no option to stack backends (use_backend is only possible in frontend). So this will result in configuration hell. So i decided not to use it.

williamdes commented 3 years ago

Okay, thanks for the feedback. I am closing this issue, let me know if you need more help