phpmyadmin / docker

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

5.2.1 Failed to set session cookie. #403

Open marlieer opened 1 year ago

marlieer commented 1 year ago

System docker image: phpmyadmin/phpmyadmin:latest phpMyAdmin: 5.2.1 PHP: 8.1.17 MySQL: MariaDB 10.2 (1:10.2.44+maria~bionic) Browser: same result on Chrome 112.0.5615.121 (Official Build) (arm64), Firefox 112.0.1 (64-bit), Safari 16.4 Docker Desktop: 4.18.0 (104112) using VirtuoFS file sharing on MacOS 13.3.1 (22E261)

I don't have a VPN or proxy

Problem Attempt signin into phpmyadmin on localhost and I get the error "Failed to set session cookie. Maybe you are using HTTP instead of HTTPS to access phpMyAdmin".

I had no issues logging in until I upgraded to MacOS 13.3.1 and Docker Desktop 4.18.0 and Virtuo filesharing. I've tried going back down to phpmyadmin/phpmyadmin:5.2.0 which was on php 8.0.19 but no luck.

What I've tried

williamdes commented 1 year ago

Because of #363 you should use docker image: phpmyadmin:latest That said, can you share your docker-compose file ? And the config file ?

marlieer commented 1 year ago

docker-compose.yml:

version: "3.7"
services:
  db:
    image: mariadb:10.2
    container_name: db_dev
    ports:
      - "5306:3306"
    restart: unless-stopped
    tty: true
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=${DB_DATABASE}
    volumes:
      - ../Mariadbdata:/var/lib/mysql/
    networks:
      - homecare
  pma:
    image: phpmyadmin/phpmyadmin
    environment:
      - PMA_HOST=db_dev
    ports:
      - "9000:80"
    container_name: pma_dev
    depends_on:
      - db
    networks:
      - homecare
networks:
  homecare:
    driver: bridge

config:

<?php

require '/etc/phpmyadmin/config.secret.inc.php';

/* Ensure we got the environment */
$vars = [
    'PMA_ARBITRARY',
    'PMA_HOST',
    'PMA_HOSTS',
    'PMA_VERBOSE',
    'PMA_VERBOSES',
    'PMA_PORT',
    'PMA_PORTS',
    'PMA_SOCKET',
    'PMA_SOCKETS',
    'PMA_USER',
    'PMA_PASSWORD',
    'PMA_ABSOLUTE_URI',
    'PMA_CONTROLHOST',
    'PMA_CONTROLPORT',
    'PMA_PMADB',
    'PMA_CONTROLUSER',
    'PMA_CONTROLPASS',
    'PMA_QUERYHISTORYDB',
    'PMA_QUERYHISTORYMAX',
    'MAX_EXECUTION_TIME',
    'MEMORY_LIMIT',
    'PMA_UPLOADDIR',
    'PMA_SAVEDIR',
];

foreach ($vars as $var) {
    $env = getenv($var);
    if (!isset($_ENV[$var]) && $env !== false) {
        $_ENV[$var] = $env;
    }
}
if (isset($_ENV['PMA_QUERYHISTORYDB'])) {
    $cfg['QueryHistoryDB'] = (bool) $_ENV['PMA_QUERYHISTORYDB'];
}

if (isset($_ENV['PMA_QUERYHISTORYMAX'])) {
    $cfg['QueryHistoryMax'] = (int) $_ENV['PMA_QUERYHISTORYMAX'];
}

/* Arbitrary server connection */
if (isset($_ENV['PMA_ARBITRARY']) && $_ENV['PMA_ARBITRARY'] === '1') {
    $cfg['AllowArbitraryServer'] = true;
}

/* Play nice behind reverse proxys */
if (isset($_ENV['PMA_ABSOLUTE_URI'])) {
    $cfg['PmaAbsoluteUri'] = trim($_ENV['PMA_ABSOLUTE_URI']);
}

/* Figure out hosts */

/* Fallback to default linked */
$hosts = ['db'];

/* Set by environment */
if (! empty($_ENV['PMA_HOST'])) {
    $hosts = [$_ENV['PMA_HOST']];
    $verbose = [$_ENV['PMA_VERBOSE']];
    $ports = [$_ENV['PMA_PORT']];
} elseif (! empty($_ENV['PMA_HOSTS'])) {
    $hosts = array_map('trim', explode(',', $_ENV['PMA_HOSTS']));
    $verbose = array_map('trim', explode(',', $_ENV['PMA_VERBOSES']));
    $ports = array_map('trim', explode(',', $_ENV['PMA_PORTS']));
}

if (! empty($_ENV['PMA_SOCKET'])) {
    $sockets = [$_ENV['PMA_SOCKET']];
} elseif (! empty($_ENV['PMA_SOCKETS'])) {
    $sockets = explode(',', $_ENV['PMA_SOCKETS']);
}

/* Server settings */
for ($i = 1; isset($hosts[$i - 1]); $i++) {
    $cfg['Servers'][$i]['host'] = $hosts[$i - 1];
    if (isset($verbose[$i - 1])) {
        $cfg['Servers'][$i]['verbose'] = $verbose[$i - 1];
    }
    if (isset($ports[$i - 1])) {
        $cfg['Servers'][$i]['port'] = $ports[$i - 1];
    }
    if (isset($_ENV['PMA_USER'])) {
        $cfg['Servers'][$i]['auth_type'] = 'config';
        $cfg['Servers'][$i]['user'] = $_ENV['PMA_USER'];
        $cfg['Servers'][$i]['password'] = isset($_ENV['PMA_PASSWORD']) ? $_ENV['PMA_PASSWORD'] : '';
    } else {
        $cfg['Servers'][$i]['auth_type'] = 'cookie';
    }
    if (isset($_ENV['PMA_PMADB'])) {
      $cfg['Servers'][$i]['pmadb'] = $_ENV['PMA_PMADB'];
      $cfg['Servers'][$i]['relation'] = 'pma__relation';
      $cfg['Servers'][$i]['table_info'] = 'pma__table_info';
      $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
      $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
      $cfg['Servers'][$i]['column_info'] = 'pma__column_info';
      $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
      $cfg['Servers'][$i]['history'] = 'pma__history';
      $cfg['Servers'][$i]['recent'] = 'pma__recent';
      $cfg['Servers'][$i]['favorite'] = 'pma__favorite';
      $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
      $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
      $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
      $cfg['Servers'][$i]['users'] = 'pma__users';
      $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
      $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
      $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
      $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
      $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
      $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
    }
    if (isset($_ENV['PMA_CONTROLHOST'])) {
      $cfg['Servers'][$i]['controlhost'] = $_ENV['PMA_CONTROLHOST'];
    }
    if (isset($_ENV['PMA_CONTROLPORT'])) {
      $cfg['Servers'][$i]['controlport'] = $_ENV['PMA_CONTROLPORT'];
    }
    if (isset($_ENV['PMA_CONTROLUSER'])) {
      $cfg['Servers'][$i]['controluser'] = $_ENV['PMA_CONTROLUSER'];
    }
    if (isset($_ENV['PMA_CONTROLPASS'])) {
      $cfg['Servers'][$i]['controlpass'] = $_ENV['PMA_CONTROLPASS'];
    }
    $cfg['Servers'][$i]['compress'] = false;
    $cfg['Servers'][$i]['AllowNoPassword'] = true;
}
for ($i = 1; isset($sockets[$i - 1]); $i++) {
    $cfg['Servers'][$i]['socket'] = $sockets[$i - 1];
    $cfg['Servers'][$i]['host'] = 'localhost';
}
/*
 * Revert back to last configured server to make
 * it easier in config.user.inc.php
 */
$i--;

/* Uploads setup */
if (isset($_ENV['PMA_UPLOADDIR'])) {
    $cfg['UploadDir'] = $_ENV['PMA_UPLOADDIR'];
}

if (isset($_ENV['PMA_SAVEDIR'])) {
    $cfg['SaveDir'] = $_ENV['PMA_SAVEDIR'];
}

if (isset($_ENV['MAX_EXECUTION_TIME'])) {
    $cfg['ExecTimeLimit'] = $_ENV['MAX_EXECUTION_TIME'];
}

if (isset($_ENV['MEMORY_LIMIT'])) {
    $cfg['MemoryLimit'] = $_ENV['MEMORY_LIMIT'];
}

/* Include User Defined Settings Hook */
if (file_exists('/etc/phpmyadmin/config.user.inc.php')) {
    include '/etc/phpmyadmin/config.user.inc.php';
}
williamdes commented 1 year ago

Okay, the config does not make more sense Did you change it ? (your docker-compose file has no mounts) Do you have some front end proxy ?

marlieer commented 1 year ago

For the config that doesn't make sense, you mean the config.inc.php file for phpmyadmin? Can I change it? I haven't touched it since pulling the image fresh from docker. I'm seeing now that its from two months ago, so maybe I have an old config... Screenshot 2023-04-20 at 15 23 11

I don't have a front-end proxy and I exluded two services from my docker-compose.yml above. Here is the full docker-compose.yml minus the environment section for app.

version: "3.7"
services:
  db:
    image: mariadb:10.2
    container_name: db_dev
    ports:
      - "5306:3306"
    restart: unless-stopped
    tty: true
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=${DB_DATABASE}
    volumes:
      - ../Mariadbdata:/var/lib/mysql/
    networks:
      - homecare
  app:
    build:
      context: .
      dockerfile: Dockerfile
    tty: true
    restart: unless-stopped
    volumes:
      - ./:/app
    container_name: app_dev
    depends_on:
      - db
    networks:
      - homecare
  web:
    image: nginx:latest
    restart: unless-stopped
    tty: true
    ports:
      - "8000:80"
    volumes:
      - ./:/app
      - ./docker-configuration/environment/development_local/canada/nginx/conf.d/:/etc/nginx/conf.d/
    container_name: web_dev
    depends_on:
      - app 
    networks:
      - homecare
networks:
  homecare:
    driver: bridge
  homecare_usa:
    driver: bridge
williamdes commented 1 year ago

Well, you are not using at all image: phpmyadmin:latest in your example. I am not sure how to assist you. It could be a nginx config issue.

In your screenshot it mentions a pma_dev container. Do you have a separate docker-compose file for this container ?

ehomecd commented 1 year ago

i have same problem image image image

marlieer commented 1 year ago

Well, you are not using at all image: phpmyadmin:latest in your example. I am not sure how to assist you. It could be a nginx config issue.

In your screenshot it mentions a pma_dev container. Do you have a separate docker-compose file for this container ?

No I don't have another docker-compose for pma_dev. It just pulls the phpmyadmin image. Sorry, I had accidentally removed it from the docker-compose.yml I sent in my second reply. It was included in my first comment's docker-compose.yml.

Last week, it started working again! I was able to login to phpmyadmin and I haven't had any issues since. I haven't changed anything that I know of, but it's working, so I'm not going to touch it haha. Thanks for your help!

rhyd42 commented 2 weeks ago

I've suddenly started getting the same problem. I don't think it's plugin related as it happens in an incognito window too.