启用身份验证网关后 phpmyadmin 500 Internal Server Error
phpmyadmin 500 Internal Server Error after enabling authentication gateway
我在 NGINX 服务器上 运行 它,在我启用身份验证网关之前它工作正常。
我使用 openssl passwd
生成了加密密码,并在 /etc/nginx/pma_pass 文件中添加了 user: encryptedPassword 行。我还在 /etc/nginx/sites-available/default 中的服务器块内添加了位置块。看起来像这样
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"
综合评论中的所有讨论,解决方案是
这样的受保护位置应该有自己的嵌套 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>
形式的行,并且不应在此类行中包含任何额外的空格。
我在 NGINX 服务器上 运行 它,在我启用身份验证网关之前它工作正常。
我使用 openssl passwd
生成了加密密码,并在 /etc/nginx/pma_pass 文件中添加了 user: encryptedPassword 行。我还在 /etc/nginx/sites-available/default 中的服务器块内添加了位置块。看起来像这样
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"
综合评论中的所有讨论,解决方案是
这样的受保护位置应该有自己的嵌套 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>
形式的行,并且不应在此类行中包含任何额外的空格。