【问题标题】:NGINX Reverse-Proxy Forbidden 403NGINX 反向代理禁止 403
【发布时间】:2018-03-21 11:32:02
【问题描述】:

我有一个问题,我有一个 express-js 网络服务器,并且我使用 nginx 反向代理托管它。我想要一个带有 .htpasswd 文件的基本身份验证。我复制了我的另一个子域的配置,实际上我有它并且它在那里工作,但在这个子域它不会工作。登录后出现错误 403。除了路径之外,配置完全相同。 这是我的配置。我已经替换了路径和域名。

upstream subdomain-domain-com{
        server 127.0.0.1:3003;
}
server {
        include cloudflare.domain.com.ssl;

        listen 443 ssl http2;
        listen [::]:443 ssl http2;


        server_name subdomain.domain.com;
        location ~ ^/(assets/|images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.$
        root /srv/www/subdomain.domain.com/www/public/;
        access_log off;
        expires 24h;
        }
         location / {
                auth_basic "Kennwort eingeben";
                auth_basic_user_file /srv/www/subdomain.domain.com/.htpasswd;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_set_header X-NginX-Proxy true;
                proxy_pass http://127.0.0.1:3003/;
                proxy_redirect off;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header x-Forwarded-Proto $scheme;
        }


}

编辑:chmod = 777 和 user = root 编辑²:如果我把 .htpasswd 的 chown 放到 nginx:nginx 什么都没有发生

【问题讨论】:

    标签: node.js express nginx cloudflare


    【解决方案1】:

    我刚刚阅读了日志,它说找不到 .htpasswd。我改变了路径,现在它的工作..

    【讨论】:

      猜你喜欢
      • 2014-10-14
      • 2020-05-07
      • 2019-06-07
      • 2019-04-17
      • 2019-06-05
      • 2019-05-29
      • 1970-01-01
      • 2019-01-28
      相关资源
      最近更新 更多