[GH-ISSUE #448] Nextcloud Nginx Conf #377

Closed
opened 2026-02-26 06:32:37 +03:00 by kerem · 8 comments
Owner

Originally created by @wuast94 on GitHub (Jun 6, 2020).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/448

How can I add the nginx conf example from nextcloud docs? https://docs.nextcloud.com/server/19/admin_manual/installation/nginx.html

when I add most of this in advanced in webui it works.

but when I add some things wich contains locations I don't get it to work:

    location / {
        rewrite ^ /index.php;
    }

    location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
        deny all;
    }
    location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }

    location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy)\.php(?:$|\/) {
        fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
        set $path_info $fastcgi_path_info;
        try_files $fastcgi_script_name =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param HTTPS on;
        # Avoid sending the security headers twice
        fastcgi_param modHeadersAvailable true;
        # Enable pretty urls
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

    location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
        try_files $uri/ =404;
        index index.php;
    }
    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }

this all. seems not to work for me :/ (as an example)

Originally created by @wuast94 on GitHub (Jun 6, 2020). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/448 How can I add the nginx conf example from nextcloud docs? https://docs.nextcloud.com/server/19/admin_manual/installation/nginx.html when I add most of this in advanced in webui it works. but when I add some things wich contains locations I don't get it to work: ``` location / { rewrite ^ /index.php; } location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ { deny all; } location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) { deny all; } location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy)\.php(?:$|\/) { fastcgi_split_path_info ^(.+?\.php)(\/.*|)$; set $path_info $fastcgi_path_info; try_files $fastcgi_script_name =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $path_info; fastcgi_param HTTPS on; # Avoid sending the security headers twice fastcgi_param modHeadersAvailable true; # Enable pretty urls fastcgi_param front_controller_active true; fastcgi_pass php-handler; fastcgi_intercept_errors on; fastcgi_request_buffering off; } location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) { try_files $uri/ =404; index index.php; } location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ { try_files $uri /index.php$request_uri; # Optional: Don't log access to other assets access_log off; } ``` this all. seems not to work for me :/ (as an example)
kerem 2026-02-26 06:32:37 +03:00
Author
Owner

@theraw commented on GitHub (Jun 8, 2020):

and why would you try to add those locations on first place?!

It's a reverse proxy it means it doesn't require any extra config for custom scripts like wordpress, laravel, nextcloud, etc.

This is the same as cloudflare nothing is different for as time as you are doing only reverse proxy with this you don't have to apply any extra config or search "nextcloud nginx config" only because you are using nginx.

You aren't using nginx for a web server you are using nginx for reverse proxy so don't add any kind of extra nginx config

here's my example totally working fine https://*******.nl and i don't have any kind of custom locations as you're trying to do on my nginx proxy manager.

<!-- gh-comment-id:640892303 --> @theraw commented on GitHub (Jun 8, 2020): and why would you try to add those locations on first place?! It's a reverse proxy it means it doesn't require any extra config for custom scripts like wordpress, laravel, nextcloud, etc. This is the same as cloudflare nothing is different for as time as you are doing only reverse proxy with this you don't have to apply any extra config or search "nextcloud nginx config" only because you are using nginx. **You aren't using nginx for a web server you are using nginx for reverse proxy so don't add any kind of extra nginx config** here's my example totally working fine https://*******.nl and i don't have any kind of custom locations as you're trying to do on my nginx proxy manager.
Author
Owner

@groundglass commented on GitHub (Jun 13, 2020):

How can I add the nginx conf example from nextcloud docs? https://docs.nextcloud.com/server/19/admin_manual/installation/nginx.html

when I add most of this in advanced in webui it works.

this all. seems not to work for me :/ (as an example)

I am running Nextcloud ver 19
This is what works for me in NPM:

  • Turn on Websockets
  • Force SSL
  • HSTS Enabled
  • HTTP/2

In Advanced

    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }

With this setting I got no security errors/warnings in NC->Settings->Admin->Security & setup warnings

<!-- gh-comment-id:643625048 --> @groundglass commented on GitHub (Jun 13, 2020): > How can I add the nginx conf example from nextcloud docs? https://docs.nextcloud.com/server/19/admin_manual/installation/nginx.html > > when I add most of this in advanced in webui it works. > > > this all. seems not to work for me :/ (as an example) I am running Nextcloud ver 19 This is what works for me in NPM: - Turn on Websockets - Force SSL - HSTS Enabled - HTTP/2 In Advanced ``` location = /.well-known/carddav { return 301 $scheme://$host:$server_port/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host:$server_port/remote.php/dav; } ``` With this setting I got no security errors/warnings in NC->Settings->Admin->Security & setup warnings
Author
Owner

@Neeham commented on GitHub (Dec 13, 2020):

In my case, I was still getting an error but after removing the :$server_port it worked. I am assuming this is because the proxy host is already port forwarding when accessing /remote.php/dav

Putting this under Advanced worked for me:

location = /.well-known/carddav {
  return 301 $scheme://$host/remote.php/dav;
}
location = /.well-known/caldav {
  return 301 $scheme://$host/remote.php/dav;
}
<!-- gh-comment-id:743926461 --> @Neeham commented on GitHub (Dec 13, 2020): In my case, I was still getting an error but after removing the **:$server_port** it worked. I am assuming this is because the proxy host is already port forwarding when accessing /remote.php/dav Putting this under Advanced worked for me: ``` location = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host/remote.php/dav; } ```
Author
Owner

@talesam commented on GitHub (Mar 6, 2021):

Where are you using this setting?

    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }

How's your docker-compose.yml? I've tried it in several ways and it's not working for me to use the nextcloud: fmp image, I get error 502.

I'm running nmp on one docker-compose file and the nextcloud on another.

If anyone can help me..

My docker-compose file:

version: '3.9'

services:
  nextcloud_db:
    image: postgres:13
    container_name: nextcloud_db
    restart: always
    volumes:
      - ./volumes/db:/var/lib/postgresql/data
    env_file:
      - db.env

  nextcloud:
    image: nextcloud:fpm
    container_name: nextcloud
    restart: always
    expose:
      - '80'
      - '9000'
    volumes:
      - ./volumes/nextcloud:/var/www/html
    environment:
      - POSTGRES_HOST=nextcloud_db
    env_file:
      - db.env
    depends_on:
      - nextcloud_db

networks:
  default:
    external:
      name: nginxproxymanager_default

This is network the proxy npm:

networks:
  default:
    external:
      name: nginxproxymanager_default

<!-- gh-comment-id:792090687 --> @talesam commented on GitHub (Mar 6, 2021): Where are you using this setting? > > ``` > location = /.well-known/carddav { > return 301 $scheme://$host:$server_port/remote.php/dav; > } > location = /.well-known/caldav { > return 301 $scheme://$host:$server_port/remote.php/dav; > } > ``` How's your docker-compose.yml? I've tried it in several ways and it's not working for me to use the nextcloud: fmp image, I get error 502. I'm running nmp on one docker-compose file and the nextcloud on another. If anyone can help me.. My docker-compose file: ``` version: '3.9' services: nextcloud_db: image: postgres:13 container_name: nextcloud_db restart: always volumes: - ./volumes/db:/var/lib/postgresql/data env_file: - db.env nextcloud: image: nextcloud:fpm container_name: nextcloud restart: always expose: - '80' - '9000' volumes: - ./volumes/nextcloud:/var/www/html environment: - POSTGRES_HOST=nextcloud_db env_file: - db.env depends_on: - nextcloud_db networks: default: external: name: nginxproxymanager_default ``` This is network the proxy npm: ``` networks: default: external: name: nginxproxymanager_default ```
Author
Owner

@spirkaa commented on GitHub (Apr 11, 2021):

Nextcloud 21

location = /.well-known/carddav {  return 301 $scheme://$host/remote.php/dav; }
location = /.well-known/caldav {  return 301 $scheme://$host/remote.php/dav; }
location ^~ /.well-known { return 301 $scheme://$host/index.php$uri; }
<!-- gh-comment-id:817257631 --> @spirkaa commented on GitHub (Apr 11, 2021): Nextcloud 21 ``` location = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host/remote.php/dav; } location ^~ /.well-known { return 301 $scheme://$host/index.php$uri; } ```
Author
Owner

@talesam commented on GitHub (Apr 11, 2021):

Nextcloud 21

location = /.well-known/carddav {  return 301 $scheme://$host/remote.php/dav; }
location = /.well-known/caldav {  return 301 $scheme://$host/remote.php/dav; }
location ^~ /.well-known { return 301 $scheme://$host/index.php$uri; }

Where do you put this? in the advanced part of npm?
Can I see what your docker-compose.yml looks like?

<!-- gh-comment-id:817330291 --> @talesam commented on GitHub (Apr 11, 2021): > Nextcloud 21 > > ``` > location = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; } > location = /.well-known/caldav { return 301 $scheme://$host/remote.php/dav; } > location ^~ /.well-known { return 301 $scheme://$host/index.php$uri; } > ``` Where do you put this? in the advanced part of npm? Can I see what your docker-compose.yml looks like?
Author
Owner

@spirkaa commented on GitHub (Apr 11, 2021):

Where do you put this? in the advanced part of npm?
Can I see what your docker-compose.yml looks like?

Yes, in the Advanced part of npm. I don't have docker-compose, i'm using ansible with unofficial all-in-one image wonderfall/nextcloud

<!-- gh-comment-id:817347480 --> @spirkaa commented on GitHub (Apr 11, 2021): > Where do you put this? in the advanced part of npm? > Can I see what your docker-compose.yml looks like? Yes, in the Advanced part of npm. I don't have docker-compose, i'm using ansible with unofficial all-in-one image `wonderfall/nextcloud`
Author
Owner

@talesam commented on GitHub (Apr 11, 2021):

I'm using the latest image that comes with apache, I wanted to test with nginx.

I´m using:

proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 16384m;
client_max_body_size 0;

location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    ```
<!-- gh-comment-id:817363629 --> @talesam commented on GitHub (Apr 11, 2021): I'm using the latest image that comes with apache, I wanted to test with nginx. I´m using: ``` proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_max_temp_file_size 16384m; client_max_body_size 0; location = /.well-known/carddav { return 301 $scheme://$host:$server_port/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host:$server_port/remote.php/dav; } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#377
No description provided.