Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextcloud Nginx Conf #448

Closed
wuast94 opened this issue Jun 6, 2020 · 8 comments
Closed

Nextcloud Nginx Conf #448

wuast94 opened this issue Jun 6, 2020 · 8 comments

Comments

@wuast94
Copy link

wuast94 commented Jun 6, 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.

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)

@theraw
Copy link
Contributor

theraw commented 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.

@groundglass
Copy link

groundglass commented 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

@wuast94 wuast94 closed this as completed Oct 6, 2020
@Neeham
Copy link

Neeham commented 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;
}

@talesam
Copy link

talesam commented 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

@spirkaa
Copy link

spirkaa commented 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; }

@talesam
Copy link

talesam commented 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?

@spirkaa
Copy link

spirkaa commented 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

@talesam
Copy link

talesam commented 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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants