小编Mik*_*ito的帖子

提供静态文件 + 反向代理时的 nginx 403

我正在尝试通过 nginx 为节点应用程序提供服务,但首先尝试为可能位于/public文件夹中的静态文件提供服务。我有那么多工作——但是在访问domain.tld/静态文件夹或索引时,我得到 403;directory index of "/var/www/domain.tld/" is forbidden. 所有权限似乎都正确,所以我很困惑。

这是我的服务器块;

server {
    server_name domain.tld;

    location / {
        root /var/www/domain.tld/public;
        try_files $uri $uri/ @proxy;
        access_log off;
    }

    location @proxy {
        proxy_pass http://127.0.0.1:3000;
    }
 }
Run Code Online (Sandbox Code Playgroud)

访问任何随机页面(包括假定的子目录)正确代理节点应用程序。但是,对于任何现有静态目录的根 / 和根,则为 403。

有任何想法吗?

nginx reverse-proxy static-files http-status-code-403

3
推荐指数
1
解决办法
8178
查看次数