PHPmyAdmin 4.8.0 - nginx代理后面的apache2 - 登录时出现session_cookie错误

时间:2018-04-10 06:15:48

标签: php nginx cookies phpmyadmin

我将PHPmyAdmin更新到ubuntu 17.10下的新版本4.8.0。我在apache 2.4.33前面有nginx 1.12.1作为代理。现在,当我尝试登录时,我收到以下错误消息:

Failed to set session cookie. Maybe you are using HTTP instead of HTTPS to access phpMyAdmin.

此前升级一切正常。通过apache-port(没有nginx)登录也可以。这是我的nginx-config:

server {

    listen 80;
    listen [::]:80;

    server_name phpmyadmin.localhost;

    index index.php index.nginx-debian.html index.html index.htm;

    location / {

        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;

        add_header X-Cache $upstream_cache_status;

        proxy_cache_valid 3s;
        proxy_no_cache $cookie_PHPSESSID;
        proxy_cache_bypass $cookie_PHPSESSID;
        proxy_cache_key $scheme$host$request_uri;

        proxy_pass http://127.0.0.1:8080/phpmyadmin$uri$is_args$args;       

    }

    location /phpmyadmin/ {

        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;

        add_header X-Cache $upstream_cache_status;

        proxy_cache_valid 3s;
        proxy_no_cache $cookie_PHPSESSID;
        proxy_cache_bypass $cookie_PHPSESSID;
        proxy_cache_key $scheme$host$request_uri;

        proxy_pass http://127.0.0.1:8080$uri$is_args$args;      

    }

}

有人知道什么是错的吗?提前谢谢。

1 个答案:

答案 0 :(得分:1)

我能够重现这个问题。

对于这个确切的配置,此问题可通过以下方式解决: 其中一个位置块中有proxy_cookie_path /phpmyadmin/ /;

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cookie_path

使用:nginx/1.14.0 (Ubuntu)