【发布时间】: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