Server:Drupal/Nginx-Konfiguration

Aus ahrensburg.city
Version vom 20. Juni 2025, 18:56 Uhr von Thorsten (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „ === Schritt 3: Nginx-Konfiguration === sudo apt-get install nginx sudo rm /etc/nginx/sites-enabled/default # Erstellen Sie eine neue Konfigurationsdatei: sudo nano /etc/nginx/conf.d/drupal.conf # Fügen Sie den folgenden Inhalt ein: server { listen 443 ssl http2; server_name drupal.ahrensburg.city; root /var/www/drupal/web; index index.php index.html; ssl_certificate /etc/letsencrypt/live/drupal.ahrensburg.city/f…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Schritt 3: Nginx-Konfiguration

sudo apt-get install nginx
sudo rm /etc/nginx/sites-enabled/default
  1. Erstellen Sie eine neue Konfigurationsdatei:
sudo nano /etc/nginx/conf.d/drupal.conf
  1. Fügen Sie den folgenden Inhalt ein:
server {
    listen 443 ssl http2;
    server_name drupal.ahrensburg.city;

    root /var/www/drupal/web;
    index index.php index.html;

    ssl_certificate      /etc/letsencrypt/live/drupal.ahrensburg.city/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/drupal.ahrensburg.city/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;

    # Sicherheitsheader
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
    add_header X-XSS-Protection "1; mode=block";

    # Gzip-Komprimierung
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

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

    location ~ \..*/.*\.php$ { return 403; }
    location ~ ^/sites/.*/private/ { return 403; }
    location ~ ^/sites/[^/]+/files/.*\.php$ { deny all; }
    location ~ (^|/)\. { return 403; }

    location / {
        try_files $uri /index.php?$query_string;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    location ~ /vendor/.*\.php$ {
        deny all;
        return 404;
    }

    location ~ '\.php$|^/update.php' {
        include fastcgi_params;
        fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTP_PROXY "";
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_intercept_errors on;
    }

    location ~ ^/sites/.*/files/styles/ {
        try_files $uri @rewrite;
    }

    location ~ ^(/[a-z\-]+)?/system/files/ {
        try_files $uri /index.php?$query_string;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
        try_files $uri @rewrite;
        expires max;
        log_not_found off;
    }
}