【问题标题】:phpmyadmin 500 Internal Server Error after enabling authentication gateway启用身份验证网关后 phpmyadmin 500 内部服务器错误
【发布时间】:2020-10-23 10:06:16
【问题描述】:

我在 NGINX 服务器上运行它,在我启用身份验证网关之前它运行良好。 我使用openssl passwd 生成了加密密码,并在 /etc/nginx/pma_pass 文件中添加了 user: encryptedPassword 行。我还在 /etc/nginx/sites-available/default 的 server 块中添加了 location 块。看起来是这样的

location /urlpath { 
    auth_basic "Admin Login";
    auth_basic_user_file /etc/nginx/pma_pass;
}

无论我放入什么,我都会收到身份验证提示,然后是 500。这可能是什么问题?

这是我的整个服务器块:

server {
        root /var/www/html;

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

        server_name www.domain domain ipaddress;

        location ^~ /urlpath {
                auth_basic "Admin Login";
                auth_basic_user_file /etc/nginx/pma_pass;
                try_files $uri $uri/ =404;
                location ~ \.php$ {
                       include snippets/fastcgi-php.conf;
                       fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                }
        }

  
        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/path; 
    ssl_certificate_key /etc/letsencrypt/path; 
    include /etc/letsencrypt/path; 
    ssl_dhparam /etc/letsencrypt/path; 

}

/var/log/nginx/error.log 最后一个条目

2020/07/04 10:57:44 [crit] 18699#18699: *530 crypt_r() failed (22: Invalid argument), client: 82.208.215.144, server: www.whatevs.info, request: "GET /path_phpadmin_is_located_at/ HTTP/1.1", host: "domain"


【问题讨论】:

  • 您需要复制根 location / { ... } 块中的所有其他指令,可能包括嵌套的 location ~ \.php$ { ... } 块并为此使用 location ^~ /urlpath { ... }
  • 您能用完整的server 块更新您的问题吗?您可以省略私人信息,例如域名、证书路径等。
  • 您正在尝试使用附加的 HTTP 基本身份验证来保护某些应用程序(看起来像是 phpMyAdmin),是吗?它物理上是否位于/var/www/html/urlpath 目录中?当您收到 500 错误时,您的 nginx 错误日志的最后几行是什么?
  • 看起来 nginx 不喜欢你的 pma_pass 文件内容(或者更准确地说,它是一个不喜欢它的系统 libc 库)。 user:password 行中不应有空格。您也可以尝试使用openssl passwd -crypt(系统默认)或openssl passwd -apr1(apache 默认)强制加密算法。
  • 另外看看thisQ/A。

标签: nginx phpmyadmin


【解决方案1】:

总结了cmets中的所有讨论,解决方法是

  • 这样一个受保护的位置应该有自己的嵌套 PHP 处理程序并使用^~ 位置修饰符(避免像/urlpath/index.php 这样的请求被下面的location ~ \.php$ { ... } 位置捕获):

    location ^~ /urlpath {
        auth_basic "Admin Login";
        auth_basic_user_file /etc/nginx/pma_pass;
        try_files $uri $uri/ =404;
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }
    }
    
  • 密码文件应包含<user_name>:<hashed_password> 形式的行,并且该行内不应包含任何多余的空格。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-03
    • 1970-01-01
    • 2013-05-30
    • 1970-01-01
    • 2019-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多