From aac33b73764102d74f06c35e9e031f6b4d8081dc Mon Sep 17 00:00:00 2001 From: Emilien Mantel Date: Thu, 11 Aug 2016 13:03:56 +0200 Subject: [PATCH] better vhost for owncloud --- .../etc/nginx/sites-available/_owncloud.j2 | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/templates/etc/nginx/sites-available/_owncloud.j2 b/templates/etc/nginx/sites-available/_owncloud.j2 index c28ea82..459f03a 100644 --- a/templates/etc/nginx/sites-available/_owncloud.j2 +++ b/templates/etc/nginx/sites-available/_owncloud.j2 @@ -28,6 +28,10 @@ add_header X-Frame-Options SAMEORIGIN; {% endblock %} +{% block template_try_files %} + try_files $uri $uri/ =404; +{% endblock %} + {% block template_upstream_location %} location ~ /remote.php { dav_methods PUT DELETE MKCOL COPY MOVE; @@ -45,7 +49,7 @@ {% endif %} } - location ~ \.php$ { + location ~ \.php(?:$|/) { fastcgi_pass {{ php_upstream }}; fastcgi_index index.php; fastcgi_param HOME {{ nginx_owncloud_root }}; @@ -59,11 +63,25 @@ include fastcgi.conf; {% endif %} } +{% endblock %} +{% block template_local_content %} location ~* \.(?:css|js)$ { try_files $uri /index.php$is_args$args; - add_header Cache-Control "public, max-age=7200"; expires 2h; + } + + location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ { + expires 2d; + } + + location = /robots.txt { + allow all; + log_not_found off; access_log off; } + + location ~ ^/(?:\.ht|data|config|db_structure\.xml|README){ + deny all; + } {% endblock %}