Nextcloud Pretty URLs - can't get rid of index.php

(Tinwasp) #1

I followed instructions over at to set up a Nextcloud “Base version - FPM” container (built with cron added) along with abiosoft’s caddy container. The caddyfile settings I used are essentially the ones from Nextcloud appears to work just as fine with this setup as it did before when I used caddy as a reverse proxy only but the url now always includes index.php/, as in instead of Apparently other users got it right ( Is there anything obvious that I’m missing or that I am doing wrong?

My Caddyfile currently contains: {

        root /srv/nextcloud

        log /Caddylog/nextcloud_access.log {
                rotate_size 10 # Rotate after 10 MB
                rotate_age  14  # Keep log files for 14 days
                rotate_keep 10  # Keep at most 10 log files
        errors stdout

        fastcgi / nextcloud:9000 php {
                root /var/www/html

        # checks for images
        rewrite {
                ext .svg .gif .png .html .ttf .woff .ico .jpg .jpeg
                r ^/index.php/(.+)$
                to /{1} /index.php?{1}

        rewrite {
                r ^/index.php/.*$
                to /index.php?{query}

        # client support (e.g. os x calendar / contacts)
        redir /.well-known/carddav /remote.php/carddav 301
        redir /.well-known/caldav /remote.php/caldav 301

        # remove trailing / as it causes errors with php-fpm
        rewrite {
                r ^/remote.php/(webdav|caldav|carddav|dav)(\/?)$
                to /remote.php/{1}

        rewrite {
                r ^/remote.php/(webdav|caldav|carddav|dav)/(.+?)(\/?)$
                to /remote.php/{1}/{2}

        rewrite {
                r ^/public.php/(.+?)(\/?)$
                to /public.php/(.+?)(\/?)$

        # .htaccess / data / config / ... shouldn't be accessible from outside
        status 403 {

        header / Strict-Transport-Security "max-age=31536000;"


The relevant section of the docker-compose.yml is


    image: abiosoft/caddy
    restart: always
      - nextcloud
      - ./Caddyfile:/etc/Caddyfile
      - ./Caddylog:/Caddylog
      - caddy-certs:/root/.caddy
      - nextcloud-data:/srv/nextcloud:ro
      - /etc/localtime:/etc/localtime:ro
      - "443:443"
      - "80:80"
    build: .
    restart: always
      - nextcloud-data:/var/www/html

(Jack) #2


you might want to check out

(Michael Munson) #3


rewrite {
if {path} starts_with .
if {path} not_starts_with .well-known
to error/index.html
rewrite {
if {file} not favicon.ico
to {path} {path}/ /index.php?{path}&{query}

That is what I use for drupal which has similar setup that everything should be redirected to index.php. May not be exactly what Nextcloud is looking for but it may be a good place to start.

(Tinwasp) #4

Thanks for the suggestions. I’ll have to look into it some more later on. For now I have reverted to using Caddy as a reverse proxy and letting Apache handle the rewrites.