覆盖子目录的NginX配置

时间:2015-12-21 14:26:44

标签: nginx subdirectory

我想在NginX Vhost的子目录中安装软件。

目前我已经:

    server {
        server_name www.website.com;
        root /var/www/website.com/www.website.com/;
        gzip_static on;

        access_log /var/log/nginx/website.com_access.log;
        error_log /var/log/nginx/website.com_error.log;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location ~* \.(txt|log)$ {
                allow 192.168.0.0/16;
                deny all;
        }

        location ~ \..*/.*\.php$ {
                return 403;
        }

        location ~ ^/sites/.*/private/ {
                return 403;
        }

        location ~ (^|/)\. {
                return 403;
        }

        location / {
                try_files $uri @rewrite;
        }

        location @rewrite {
                rewrite ^ /index.php;
        }

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                fastcgi_read_timeout 150;
                fastcgi_intercept_errors on;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
        }

        location ~ ^/sites/.*/files/styles/ {
                try_files $uri @rewrite;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}

现在我尝试了子目录:

    location /mseiten/ {
            try_files $uri $uri/ /mseiten/index.php?q=$request_uri;
            allow all;
            root /var/www/website.com/www.website.com;
    }

但是如果我尝试在我的浏览器中访问/ mseiten /那么我所看到的就是403(它应该指引我到我的安装向导)。我已取消注释所有return 403;但具有相同结果的规则。 是否可以设置......像一个子目录的干净的石板?

0 个答案:

没有答案