NGINX bietet intern abgerufene Seiten nur zum Download an, extern geht's

O

olma

Grünschnabel
Moin, liebe Gemeinde!

Manchmal ist man ja zu blöd oder sieht den Wald vor lauter Bäumen nicht mehr. Weshalb ich jetzt einfach mal hier nachfrage.
Situation:
NGINX Webserver hinter Fritz!Box, mit DynDNS/DNS-Routing auf externe IP.
Die Webseiten sind von extern unter <domain> erreichbar. Läuft astrein.
Die Webseiten sind nicht unter <interne IP> erreichbar. Es werden PHP-Seiten nur zum Download angeboten und nicht serverseitig verarbeitet.
Ich gehe davon aus, dass der Fehler irgendwo in der NGINX Konfiguration der Site zu suchen ist. Hier mal die entsprechende Sitekonfig:

NGINX:
upstream php-handler {
    #server 127.0.0.1:9000;
    server unix:/var/run/php/php8.0-fpm.sock;
}

server {
    listen 80;
    listen [::80;
    server_name meine.domain.de;
    # enforce https
    return 301 https://$server_name:443$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::443 ssl http2;
    server_name meine.domain.de;

    ssl_certificate /etc/letsencrypt/live/meine.domain.de/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/meine.domain.de/privkey.pem;

    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
    add_header Referrer-Policy "no-referrer" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Download-Options "noopen" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Permitted-Cross-Domain-Policies "none" always;
    add_header X-Robots-Tag "none" always;
    add_header X-XSS-Protection "1; mode=block" always;
    fastcgi_hide_header X-Powered-By;

    root /var/www/html/;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log 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;
    }

    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;

    # Enable gzip but do not remove ETag headers
    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 / {
        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\/.+)\.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;
    }

    # Adding the cache control header for js, css and map files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
        add_header Referrer-Policy "no-referrer" always;
        add_header X-Content-Type-Options "nosniff" always;
        add_header X-Download-Options "noopen" always;
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Permitted-Cross-Domain-Policies "none" always;
        add_header X-Robots-Tag "none" always;
        add_header X-XSS-Protection "1; mode=block" always;

        # Optional: Don't log access to assets
        access_log off;
    }

    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }
}

Wer kann mich in die richtige Richtung schubsen?
Ich danke euch jetzt schon mal.
 
ohne es ausprobiert zu haben - vermutlich matcht der server_name nicht und damit kommt der default-VHost zum Zuge - der vermutlich das gleiche DocRoot hat, aber halt sonst nur "default-liefer-alles-aus-Konfig".
 
Hallo, marce!

Vielen Dank für Deine Antwort.

Du hast recht. Er scheint sich die default zu holen. Da dort aber nicht die index.php aktiviert ist, lädt er die Datei runter.
Jetzt ist die Frage, wieso er die default benutzt.
Ich habe den Servernamen noch mal gecheckt. Es stimmt alles.
server_name = hostname -f = <domain>

Wenn ich
Code:
 server_name "$hostname"
                ""
                10.10.10.100;
eintrage und versuche die Seite über die IP abzurufen, schickt er mich auf die Benutzeroberfläche der Fritz!Box. Der externe Aufruf funktioniert dann auch nicht mehr.
Ich hatte auch mal
Code:
server_name = "_";
(mit und ohne IP Angabe) probiert, aber da hat sich dann NGINX beschwert:
Code:
nginx: [warn] conflicting server name "_" on 0.0.0.0:80, ignored
Ich kapier's nicht.
 
zu den ersten beiden Punkten - da kenne ich Deine Konfiguration - da bräuchte man mehr Infos, die Einträge müssen halt valide sein.

... zum letzen Punkt: Da steckt irgendwo ein Default-Eintrag. Finde den, passe den an oder entferne ihn.
(oder pack die richtigen Werte in die server_name-Direktive)

Alternativ - poste die komplette Nginx-Konfig.
 
Nachdem ich in den Konfigs hin- und herprobiert habe und ich kein zufriedenstellendes Ergebnis erhalten habe, habe ich das Ganze jetzt noch mal mit dem Indianer nachgebaut und siehe da, es läuft. Woran es jetzt nun also bei NGINX genau gehapert hat, kann ich nicht sagen.
Ich danke Dir aber für Deinen Einsatz, marce!
 

Ähnliche Themen

Nginx als Reverse Proxy für Nextcloud und Emby

nginx+php-fpm problem

nginx owncloud, php? Problem

dovecot und postfix Konfiguration Problem

Debian squeeze, Webmin, Samba Freigaben

Zurück
Oben