# nginx und nextcloud webdav - bad Gateway



## merlin2k11 (24. März 2017)

Hallo,
ich habe ja nun den Debian Server mit ISPConfig und nginx laufen.
Der Versuch aber nextcloud ans laufen zu bekommen scheiter kläglich. 

Im Webinterface von Nextcloud wird mir angezeigt:

Ihr Webserver ist noch nicht hinreichend für Datei-Synchronisation konfiguriert. Die WebDAV-Schnittstelle ist vermutlich defekt.
Ich habe nun schon mehrere einstellungen versucht. Allerdings bekomme ich diese Fehlermeldung nicht beseitigt.
Wenn ich mich mit dem Desktop Client verbinden möchte erhalte ich einen Fehler "Errod downloading hhtps://*****/remote.php/webdav/ - server replied: Bad Gateway"


Was muss ich machen das das ganze läuft?

Danke, gruß Armin

Meine aktuelle vhost

```
server {
        listen *:80;

        listen *:443 ssl;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_certificate /var/www/clients/client1/web24/ssl/nextcloud.tld.de-le.crt;
        ssl_certificate_key /var/www/clients/client1/web24/ssl/nextcloud.tld.de-le.key;

        server_name nextcloud.tld.de ;

        root   /var/www/nextcloud.tld.de/web/;

        if ($scheme != "https") {
            rewrite ^ https://$http_host$request_uri? permanent;
        }

        index index.html index.htm index.php index.cgi index.pl index.xhtml;
        error_page 400 /error/400.html;
        error_page 401 /error/401.html;
        error_page 403 /error/403.html;
        error_page 404 /error/404.html;
        error_page 405 /error/405.html;
        error_page 500 /error/500.html;
        error_page 502 /error/502.html;
        error_page 503 /error/503.html;
        recursive_error_pages on;
        location = /error/400.html {

            internal;
        }
        location = /error/401.html {

            internal;
        }
        location = /error/403.html {

            internal;
        }
        location = /error/404.html {

            internal;
        }
        location = /error/405.html {

            internal;
        }
        location = /error/500.html {

            internal;
        }
        location = /error/502.html {

            internal;
        }
        location = /error/503.html {

            internal;
        }

        error_log /var/log/ispconfig/httpd/nextcloud.tld.de/error.log;
        access_log /var/log/ispconfig/httpd/nextcloud.tld.de/access.log combined;

        location ~ /\.(?!well-known/acme-challenge/) {
            deny all;
            access_log off;
            log_not_found off;
        }

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location /stats/ {
            index index.html index.php;
            auth_basic "Members Only";
            auth_basic_user_file /var/www/clients/client1/web24/web/stats/.htpasswd_stats;
        }

        location ^~ /awstats-icon {
            alias /usr/share/awstats/icon;
        }

        location ~ \.php$ {
            try_files /49ba9ed4c464baa4e01bd6644ca4d5a6.htm @php;
        }

        location @php {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/lib/php5-fpm/web24.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
        }

        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 360;
        add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";

        location / {
                        rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
                        rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
                        rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
                        rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
                        rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
                        try_files $uri $uri/ /index.php?$args;
        }

        location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
                        expires 30d;
                        access_log off;
        }

        location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
                        deny all;
        }

        location ~ /remote.php {
                        dav_methods PUT DELETE MKCOL COPY MOVE;
                        dav_ext_methods PROPFIND OPTIONS;
                        fastcgi_split_path_info ^(.+\.php)(/.+)$;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include fastcgi_params;
                        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        }

        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/acme-challenge {
         }

        location ~ /\.well-known/acme-challenge/ {
       root /usr/local/ispconfig/interface/acme/;
       index index.html index.htm;
       try_files $uri =404;
        }

    rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
}
```


----------



## florian030 (25. März 2017)

Bei mir läuft das u.a. mit:

```
location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.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_param modHeadersAvailable true; #Avoid sending the security headers twice
        fastcgi_param front_controller_active true;
       fastcgi_pass  unix:/var/lib/php5-fpm/webX.sock;
        fastcgi_intercept_errors on;
       fastcgi_request_buffering off; #Available since nginx 1.7.11
    }
```


----------

