Ankündigung

Einklappen
Keine Ankündigung bisher.

[OT] Nginx Reverse Proxy debuggen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    [OT] Nginx Reverse Proxy debuggen

    Hallo,

    ich habe bisher einen nginx reverse-proxy für bitwarden und die smartvisu in Benutzung:
    Code:
    #bitwarden
    server {
        listen 443 ssl;
        server_name henfri-pass.my-url.de;
        ssl_certificate /etc/letsencrypt/live/henfri-pass.my-url.de/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/henfri-pass.my-url.de/privkey.pem;
        access_log /var/log/nginx/henfri-bitwarden.log combined;
        include /etc/nginx/include.d/common;
    
        location / {
            proxy_pass http://192.168.177.3:8087/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
    Nun wollte ich das Gleiche für owncloud machen:
    Code:
    # owncloud
    server {
        listen 443 ssl;
        server_name henfri-owncloud.my-url.de;
        ssl_certificate /etc/letsencrypt/live/henfri-owncloud.my-url.de/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/henfri-owncloud.my-url.de/privkey.pem;
        access_log /var/log/nginx/henfri-owncloud.log combined;
        error_log /var/log/nginx/henfri-owncloud-error.log debug;
        include /etc/nginx/include.d/common;
    
        location / {
            proxy_pass http://192.168.177.3:8081/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
    Da ist also nix anders -soweit ich sehe- als:
    1) henfri-owncloud statt henfri-pass in der URL und den zertifikaten
    2) Debug-log
    3) Ziel (proxy_pass)

    leider kommt aber auf einem Gerät auf dem henfri-pass.my-url.de funkitioniert beim Aufruf von henfri-owncloud.my-url.de:
    ERR_CONNECTION_REFUSED

    Jetzt könnte man meinen, das läge an owncloud, aber ich habe (3) auch mal auf bitwarden umgebogen (port eben auf 8087) - keine Änderung.

    Ein ping von henfri-pass.my-url.de und henfri-owncloud.my-url.de führt auf die gleiche IP.

    Die /var/log/henfri-owncloud-error.log und henfri-owncloud.log bleiben leer -werden aber erzeugt. Das wundert mich sehr.

    Hat jemand noch eine Idee?

    Gruß,
    Hendrik

    #2
    Hallo,

    ein Unterschied fällt mir gerade auf:
    Bei bitwarden läuft intern (d.h. der Webserver auf dem Host) http. Bei Owncloud läuft intern https.

    Ist in diesem Fall etwas zu beachten?

    Warum will ich dann überhaupt einen Reverse Proxy?
    1) um die Portweiterleitung zu umgehen
    2) um extern den den Dienst über eine Subdomain verfügbar zu machen statt über einen non-standard Port (80 und 443 sind schon verbraucht)

    Gruß,
    Hendrik

    Kommentar


      #3
      Ich habe leider keine Lösung, aber ich bewundere das Problem

      Nur interessehalber von Nachbar zu Nachbar: Die Dienste klingen danach, als wäre nur ein Zugriff für einen kleinen Personenkreis gedacht: Wäre da nicht eine Lösung a la tailscale einfacher?

      Gruß
      Leif

      Kommentar


        #4
        Hallo Leif,

        hallo in die Nachbarschaft.
        VPN bekomme ich hin, die Nutzer auf die ich ziele aber nicht.

        Ich habe mittlerweile herausgefunden, dass Owncloud nur Verbindungen von bestimmten Domains&Proxies akzeptiert. Daran könnte es liegen. Allerdings habe ich Owncloud meine Domain und meinen Proxy bekannt gemacht - ohne Erfolg.

        Ich habe derweil mal per Portfreigabe darauf zugegriffen um das alles auszuprobieren. Die App wirkt recht altbacken... Ich glaube das wird eh nicht angenommen. Ich denke, ich werde den Verwandten ein Google-One Abo empfehlen. Dann hat der Familienadmin auch weniger Ärger.

        Gruß,
        Hendrik

        Kommentar


          #5
          Zitat von henfri Beitrag anzeigen
          Dann hat der Familienadmin auch weniger Ärger.
          Das ist mindestens genauso wichtig wie die Tatsache, dass es überhaupt funktioniert.

          Ich hab - mangels Kenntnis - hier nur mit erheblichem Aufwand OpenVPN zum laufen bekommen. Die Einstellung der Router der anderen Familienmitglieder war ein Graus

          Jetzt mit Tailscale: App installiert, fertig. Keine Routen, keine statische IP, nix. Läuft dauernd im HIntergrund, keiner merkt was und es funktioniert einwandfrei. Und der Familienadmin hat seine Ruhe

          Ein schönes Wochenende!

          Kommentar


            #6
            Hi,

            also ich nutze Nextcloud und musste dafür in der Config einiges umstellen. Ab dem Reverseproxy läuft die Nextcloud bei mir mit http und ist nicht verschlüsselt.

            Grüße

            Kommentar


              #7
              Hallo,

              ja, tatsache, bei mir ist es auch intern nicht https, sondern http. Also kein Unterschied zur Smartvisu.

              Weißt du noch, was du umstellen musstest? Es gibt natürlich tonnenweise tutorials, aber immer ist Reverse Proxy UND Nextcloud im Docker. Ich hab nur Nextcloud nicht aber den RP im Docker

              Gruß,
              Hendrik

              Kommentar


                #8


                Also meine oberer Teil der Nextcloud-Config sieht so aus:

                Code:
                <?php
                $CONFIG = array (
                'instanceid' => 'sgerdherger',
                'passwordsalt' => 'argedhrtshgargwregesgweg',
                'secret' => 'wefwefw+fewfg4f4f2fqf3f23f32f322' ,
                'trusted_domains' =>
                array (
                0 => 'https://name',
                1 => '10.10.100.2',
                2 => 'https://name.domain.de',
                4 => 'https://10.10.100.2',
                5 => 'http://name.domain.de',
                6 => '10.10.100.1',
                7 => 'https://10.10.100.1',
                8 => 'http://name',
                ),
                'datadirectory' => '/daten',
                'dbtype' => 'mysql',
                'version' => '22.2.0.2',
                'overwrite.cli.url' => 'https://name.domain.de',
                'overwriteprotocol' => 'https',
                'overwritehost' => 'name.domain.de',
                'overwritewebroot' => '/',

                Im Reverseproxy unter Nginx habe ich folgendes stehen:
                Code:
                server {
                listen 443 ssl http2;
                server_name name.domain.de;
                
                # Errorpages einbinden
                include /etc/nginx/snippets/error.conf;
                
                ssl_certificate /etc/letsencrypt/live/name.domain.de/fullchain.pem;
                ssl_certificate_key /etc/letsencrypt/live/name.domain.de/privkey.pem;
                ssl_trusted_certificate /etc/letsencrypt/live/name.domain.de/chain.pem;
                ssl_dhparam /etc/ssl/certs/dhparam.pem;
                ssl_session_timeout 1d;
                ssl_session_cache shared:SSL:10m;
                ssl_session_tickets off;
                ssl_protocols TLSv1.3 TLSv1.2;
                ssl_ciphers 'TLS-CHACHA20-POLY1305-SHA256:TLS-AES-256-GCM-SHA384:ECDHE-RSA-AES256-GCM- SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384';
                ssl_ecdh_curve X448:secp521r1:secp384r1;
                ssl_prefer_server_ciphers on;
                ssl_stapling on;
                ssl_stapling_verify on;
                client_max_body_size 10240M;
                fastcgi_buffers 64 4K;
                gzip on;
                gzip_vary on;
                gzip_comp_level 4;
                gzip_min_length 256;
                gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
                gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms- fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest
                text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain- policy;
                location ^~ / {
                add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload;" always;
                add_header X-Content-Type-Options "nosniff" always;
                add_header X-XSS-Protection "1; mode=block" always;
                add_header X-Robots-Tag none always;
                add_header X-Download-Options noopen always;
                add_header X-Permitted-Cross-Domain-Policies none always;
                add_header Referrer-Policy "no-referrer" always;
                add_header X-Frame-Options "SAMEORIGIN" always;
                fastcgi_hide_header X-Powered-By;
                proxy_connect_timeout 3600;
                proxy_send_timeout 3600;
                proxy_read_timeout 3600;
                proxy_buffering off;
                proxy_request_buffering off;
                proxy_max_temp_file_size 10240m;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_pass http://10.10.100.2;
                proxy_redirect off;
                }
                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;
                }
                
                # The following 2 rules are only needed for the user_webfinger app.
                # Uncomment it if you're planning to use this app.
                rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
                rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
                
                # The following rule is only needed for the Social app.
                # Uncomment it if you're planning to use this app.
                rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
                
                location ^~ /.well-known {
                # The rules in this block are an adaptation of the rules
                # in the Nextcloud `.htaccess` that concern `/.well-known`.
                location = /.well-known/carddav { return 301 $scheme://$host/nextcloud/remote.php/dav/; }
                location = /.well-known/caldav { return 301 $scheme://$host/nextcloud/remote.php/dav/; }
                location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
                location /.well-known/pki-validation { try_files $uri $uri/ =404; }
                # Let Nextcloud's API for `/.well-known` URIs handle all other
                # requests by passing them to the front-end controller.
                return 301 $scheme://$host/nextcloud/index.php$request_uri;
                }
                
                }
                Im Nextcloudserver hab ich im Ordner /ect/nginx/conf.d/ die Datei http.conf gelöscht bzw. die Endung umbenannt zu.conf.bak.


                Danach im gleiche Ordner die Nextcloud.conf umbiegen. Bei mir läuft es mit folgender Einstellung:

                Code:
                upstream php-handler {
                server unix:/run/php/php8.0-fpm.sock;
                }
                
                server {
                listen 80;
                server_name name.domain.de;
                
                client_max_body_size 10G;
                fastcgi_buffers 64 4K;
                gzip on;
                gzip_vary on;
                gzip_comp_level 4;
                gzip_min_length 256;
                gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
                gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
                add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
                add_header Permissions-Policy "interest-cohort=()";
                add_header Referrer-Policy "no-referrer" always;
                fastcgi_hide_header X-Powered-By;
                root /var/www/nextcloud;
                index index.php index.html /index.php$request_uri;
                location = / {
                if ( $http_user_agent ~ ^DavClnt ) {
                return 302 /remote.php/webdav/$is_args$args;
                }
                }
                location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
                }
                location ^~ /apps/rainloop/app/data {
                deny all;
                }
                
                
                location ^~ /.well-known {
                
                location = /.well-known/webfinger { return 301 /index.php$uri; }
                
                location = /.well-known/carddav { return 301 /remote.php/dav/; }
                location = /.well-known/caldav { return 301 /remote.php/dav/; }
                location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
                location /.well-known/pki-validation { try_files $uri $uri/ =404; }
                return 301 /index.php$request_uri;
                }
                
                location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data) (?:$|/) { return 404; }
                location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
                location ~ \.php(?:$|/) {
                rewrite ^/(?!index|test|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri;
                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;
                fastcgi_param modHeadersAvailable true;
                fastcgi_param front_controller_active true;
                fastcgi_pass php-handler;
                fastcgi_intercept_errors on;
                fastcgi_request_buffering off;
                fastcgi_read_timeout 3600;
                fastcgi_send_timeout 3600;
                fastcgi_connect_timeout 3600;
                }
                location ~ \.(?:css|js|svg|gif|png|jpg|ico)$ {
                try_files $uri /index.php$request_uri;
                expires 6M;
                access_log off;
                }
                location ~ \.woff2?$ {
                try_files $uri /index.php$request_uri;
                expires 7d;
                access_log off;
                }
                location /remote {
                return 301 /remote.php$request_uri;
                }
                location / {
                try_files $uri $uri/ /index.php$request_uri;
                }
                }


                Wie man die Nextcloud installiert oder installieren lässt mit einem Script habe ich von hier https://www.c-rieger.de/nextcloud-in...-einem-skript/

                Ich hoffe das hilft dir schonmal ein wenig weiter....

                Kommentar


                  #9
                  Hallo,

                  vielen Dank.
                  Da sieht der relevante Teil so aus wie bei mir.

                  Ich habe das mal als Ermutigung genommen.... Ich hatte es bisher immer vom Handy probiert (da nicht im gleichen Netzwerk und ich hatte da schon komische Effekte, auch wenn eigentlich das gleiche Netzwerk noch einfacher sein sollte). Jetzt hab ich es vom PC probiert. Ging sofort.
                  Dann nochmal auf dem Handy -- geht nicht.
                  URL aus dem Browser am PC per mail ans Handy kopiert -- geht.
                  Huch... Aber kein Tippfehler zu sehen.

                  Die Lösung: der Desktop-browser macht automatisch ein https:// davor. Am Handy (beides Chrome) funktioniert es nur, wenn man manuell https:// vor die Domain packt - ich vermute, er versucht sonst eine http-Verbindung.

                  So einfach war es!

                  Gruß und Danke für die Tipps!,
                  Hendrik

                  Kommentar

                  Lädt...
                  X