使用nginx仅允许访问index.php和一个公共目录

使用nginx仅允许访问index.php和一个公共目录,nginx,configuration,webserver,Nginx,Configuration,Webserver,我想允许免费访问/index.php以及/public folder及其所有子文件夹。不幸的是,无论我尝试什么,Nginx仍然拒绝连接,无论是我还是我的脚本(嵌套在html模板中,它们需要访问公用文件夹才能获得一些资源,如css) 与所有其他路径一样,当我尝试打开public时,会得到403。但是,index.php的一切都很好(允许访问)。Nginx进程由www数据处理,公用文件夹拥有所有良好的权限。我错过什么了吗 以下是我的nginx配置: server { server_

我想允许免费访问
/index.php
以及
/public folder
及其所有子文件夹。不幸的是,无论我尝试什么,Nginx仍然拒绝连接,无论是我还是我的脚本(嵌套在html模板中,它们需要访问公用文件夹才能获得一些资源,如
css

与所有其他路径一样,当我尝试打开
public
时,会得到
403
。但是,index.php的一切都很好(允许访问)。Nginx进程由www数据处理,公用文件夹拥有所有良好的权限。我错过什么了吗

以下是我的nginx配置:

server {

        server_name dev;

        listen  80;
        listen  [::]:80 ipv6only=on;

        return  301 https://$server_name$request_uri;

}

server {

        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;

        server_name dev;
        listen 443 default_server ssl;
       ssl on;
        ssl_certificate ssl/dev.cert;
        ssl_certificate_key ssl/dev.nopass.key;
        ssl_session_timeout 5m;
        #ssl_protocols TLSv1;
        ssl_prefer_server_ciphers on;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+EXP;

        root /var/www/awesomeProject;
        index index.php;

        # deny everything that doesn't match another location
        location / { deny all; }

        location = / { } # need to allow GET / to internally redirect to /index.php

        location /index.php {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/tmp/php.sock;
        }

location = /public { allow all; }

}

我被Nginx中默认禁止列出目录的事实弄糊涂了。上述配置适用于真正的文件,如
/public/style.css


多亏了

Just
location/public{}
应该可以工作。它没有:/i不明白是什么问题……它说:“/var/www/awesomeProject/public/”的目录索引是被禁止的,客户机:127.0.0.1,服务器:dev,请求:“GET/public/HTTP/1.1”,主机:“dev”你想要列表还是想要来自
/public
的文件?需要一些真正的文件,比如
/public/style.css
/public/style.css
有效。我现在明白了,我不知道上市是被默认禁止的。。。我的错,我的困惑。谢谢你@Alexey