gpt4 book ai didi

windows - nginx 的密码文件应该放在哪里

转载 作者:可可西里 更新时间:2023-11-01 10:32:42 26 4
gpt4 key购买 nike

我正在关注适用于 Windows 的 elasticsearch nginx 集成教程。我已经使用 openssl 生成了密码。

问题是密码文件的扩展名应该是什么以及它应该放在哪里。

我不断收到此错误消息,但我不太清楚到底是什么问题

C:\Program Files\nginx-1.12.1\nginx-1.12.1>nginx -s reload nginx: [error] OpenEvent("Global\ngx_reload_4428") failed (2: The system cannot find the file specified)

目前,该文件存在于 configs 目录中

events {
worker_connections 1024;
}

http {

upstream elasticsearch {
server 127.0.0.1:9200;
}

server {
listen 8080;

auth_basic "Protected Elasticsearch";
auth_basic_user_file passwords;

location / {
proxy_pass http://elasticsearch;
proxy_redirect off;
}
}

}

最佳答案

您必须指定密码文件位置的完整路径:

location / {
auth_basic "Secure Area (or whatever description you want)";
auth_basic_user_file /etc/nginx/auth/nginx.passwd;
... (other settings)
}

上面的示例适用于运行 nginx 的 Unix/Linux 服务器。由于您运行的是 Windows,我想您必须指定完整路径,如 C:\Program Files\nginx-1.12.1\nginx-1.12.1\nginx.passwd

根据您想要限制的具体内容,您可能需要将规则放在 location/{} block 的内部或外部。假设您需要允许对您的服务器/站点的完全访问权限并且只限制让我们说/private 那么您将在以下位置添加基本身份验证:

location /private {
...
}

关于windows - nginx 的密码文件应该放在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45498618/

26 4 0