Skip to content

Instantly share code, notes, and snippets.

@overheadhunter
Created October 21, 2014 07:05
Show Gist options
  • Save overheadhunter/e8e89a1444bd2420b5e6 to your computer and use it in GitHub Desktop.
Save overheadhunter/e8e89a1444bd2420b5e6 to your computer and use it in GitHub Desktop.
For ownCloud installations on example.com/owncloud instead of a own subdomain.
location /owncloud/ {
error_page 403 = /owncloud/core/templates/403.php;
error_page 404 = /owncloud/core/templates/404.php;
client_max_body_size 0;
proxy_buffering off;
rewrite ^/owncloud/caldav(.*)$ /owncloud/remote.php/caldav$1 redirect;
rewrite ^/owncloud/carddav(.*)$ /owncloud/remote.php/carddav$1 redirect;
rewrite ^/owncloud/webdav(.*)$ /owncloud/remote.php/webdav$1 redirect;
# The following 2 rules are only needed with webfinger
rewrite ^/owncloud/.well-known/host-meta /owncloud/public.php?service=host-meta break;
rewrite ^/owncloud/.well-known/host-meta.json /owncloud/public.php?service=host-meta-json break;
rewrite ^/owncloud/.well-known/carddav /owncloud/remote.php/carddav/ redirect;
rewrite ^/owncloud/.well-known/caldav /owncloud/remote.php/caldav/ redirect;
rewrite ^/owncloud(/core/doc/[^\/]+/)$ /owncloud$1/index.html;
try_files $uri $uri/ index.php;
location ~ ^/owncloud/(?:\.htaccess|data|config|db_structure\.xml|README) {
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_buffers 64 4K;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass unix:/var/lib/php5-fpm/web.sock;
}
# Optional: set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
access_log off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment