nginx配置:访问静态文件 403 forbidden

发布于 2022-09-01 21:10:06 字数 1278 浏览 12 评论 0

nginx配置:

    server {
            listen 443;
            server_name localhost;
            ssl on;
            ssl_certificate /home/attolee/sslkey/example.crt;
            ssl_certificate_key /home/attolee/sslkey/example.key;
            ssl_session_timeout 5m;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_ciphers ALL:!ADH:!EXPORT56:-RC4+RSA:+HIGH:+MEDIUM:!EXP;
            ssl_prefer_server_ciphers on;

            location / {
                    root /home/a;
                    index index.html;
            }

            location /b/ {
                    root /home/a;
                    index b.html;
            }
   }

我想让

  1. https://host/可以访问到/home/a/index.html,

  2. https://host/b可以访问到/home/a/b/b.html,

现在1成功,2没有成功,403 Forbidden,请问,配置哪里出了问题?

更新

更详细的问题描述:403 forbidden of nginx in ubuntu

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

空‖城人不在 2022-09-08 21:10:06

root需要x权限:

d--------x  2 attolee attolee  4096 11月  2 21:54 hi/
挽梦忆笙歌 2022-09-08 21:10:06

上面两位的回答都是错的!
我来给你讲讲吧:
下面那个location应该改成
location /b/ {

                root /home/a/b;
                index b.html;
        }
生寂 2022-09-08 21:10:06

把两个location顺序反过来
另外根据你这个配置 应该是https://host/b/能否访问到/home/a/b/b.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文