nginx`/ var / www / foo / current / public`禁止错误403

时间:2017-03-20 16:00:07

标签: ruby-on-rails ubuntu nginx capistrano3

Nginx默认配置文件 - /etc/nginx/sites-available/foo

upstream puma {
     server unix:///var/www/foo/shared/tmp/sockets/foo-puma.sock;
   }

server {
    listen 80;
    listen [::]:80;
    server_name foo.com;

      if ($http_user_agent ~* (easou|Gimme60bot) ) {
          return 403;
      }
      root /var/www/foo/current/public;

      client_max_body_size 15M;
      keepalive_timeout 10;


      location ~ ^/(images|stylesheets|javascripts|fonts) {
      expires max;
      add_header Cache-Control public;
      add_header Access-Control-Allow-Origin *;
      }

      location ^~ /assets/ {
       gzip_static on;
       expires max;
       add_header Cache-Control public;
      }

    location ~* ^.*system.*\.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
      gzip_static on;
      expires max;
      add_header Cache-Control public;
    }

}
[error] 10400#10400: *2 directory index of "/var/www/foo/current/public/" is forbidden, client: 10.16.10.20, server: foo.com, request: "GET / HTTP/1.1", host: "www.foo.com", referrer: "http://www.foo.com/"

我也尝试更改current/public目录权限,但它不起作用。 sudo chown -R www-data:www-data /var/www/foo/current/public                   要么 sudo chown -R deploy:deploy /var/www/foo/current/public

0 个答案:

没有答案