Rendez-vous sur Arrakis

C'est lorsque nous croyons savoir quelque chose qu'il faut justement réfléchir un peu plus profondément. F. Herbert

Owncloud dans un sous dossier

Quand on n'a pas accès à des sous-domaines, la configuration de nginx pour owncloud dans un sous-dossier peut être énervante. Voici donc le fichier que j'utilise pour accéder à owncloud à l'adresse http://mondomaine.com/owncloud

# nginx config to have owncloud in a subdirectory
# access via http://domain.net/owncloud/
# replace yeuxdelibad.net by your domain

# redirect http to https.
server {
listen 80;
server_name yeuxdelibad.net;
return 301 https://$server_name$request_uri;  # enforce https
}

# owncloud (ssl/tls)
server {
listen 443 ssl;

ssl_certificate /etc/ssl/private/yeuxdelibad.net.pem;
ssl_certificate_key /etc/ssl/private/yeuxdelibad.net.pem;
server_name yeuxdelibad.net;
root /media/PIDATA/www/owncloud/;
index index.php;
client_max_body_size 1500M; # set maximum upload size
fastcgi_buffers 64 4K;

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;

    location /owncloud {
        error_page 403 /owncloud/core/templates/403.php;
        error_page 404 /owncloud/core/templates/404.php;
            # The following 2 rules are only needed with webfinger
            rewrite ^/owncloud/.well-known/host-meta /owncloud/public.php?service=host-meta last;
            rewrite ^/owncloud/.well-known/host-meta.json /owncloud/public.php?service=host-meta-json last;

            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/ /owncloud/index.php;
    }

    location = /owncloud/robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
# deny direct access
location ~ ^/owncloud/(data|config|.ht|db_structure.xml|README) {
    deny all;
}

    location ~ .php(?:$|/) {
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        include 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/run/php5-fpm.sock;
    }

    # Optional: set long EXPIRES header on static assets
    location ~* ^/owncloud/.+.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
            expires 30d;
            # Optional: Don't log access to assets
            access_log off;
    }

}