Skip to content

Instantly share code, notes, and snippets.

@ef4
Created August 31, 2013 18:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ef4/6399951 to your computer and use it in GitHub Desktop.
Save ef4/6399951 to your computer and use it in GitHub Desktop.
nginx config for owncloud
server {
listen 80;
return 301 https://$server_name$request_uri; # enforce https
}
server {
listen 443 ssl;
ssl_certificate your_certificate_filename;
ssl_certificate_key your_certificate_key;
root /var/www;
client_max_body_size 10G; # set max upload size
fastcgi_buffers 64 4K;
# Use ownCloud's robots
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
root /var/lib/owncloud/public;
}
# Rewrites into ownCloud
rewrite ^/caldav(.*)$ /owncloud/remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /owncloud/remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /owncloud/remote.php/webdav$1 redirect;
rewrite ^/.well-known/host-meta /owncloud/public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /owncloud/public.php?service=host-meta-json last;
rewrite ^/.well-known/carddav /owncloud/remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /owncloud/remote.php/caldav/ redirect;
# ownCloud blacklist
location ~ ^/owncloud/(data|config|\.ht|db_structure\.xml|README) {
deny all;
error_page 403 = /owncloud/core/templates/403.php;
}
# ownCloud static
location /owncloud {
alias /var/lib/owncloud/public;
index index.php index.html;
error_page 403 = /owncloud/core/templates/403.php;
error_page 404 = /owncloud/core/templates/404.php;
}
# ownCloud dynamic
location ~ ^/owncloud(/.+?\.php)(/.*)?$ {
alias /var/lib/owncloud/public$1;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /public$1;
fastcgi_param PATH_INFO $2;
fastcgi_param HTTPS on;
fastcgi_param DOCUMENT_ROOT /public;
fastcgi_param SCRIPT_NAME /owncloud$1;
fastcgi_param DOCUMENT_URI /owncloud$1;
fastcgi_pass unix:/var/run/php5-fpm-owncloud.sock;
}
# ownCloud cacheable assets
location ~* ^/owncloud(/.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf|svg))$ {
alias /var/lib/owncloud/public$1;
expires 30d;
access_log off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment