# Default server configuration
#

server {
    listen 80 default_server;
    server_name solusar.de www.solusar.de;
    
    location / {
        return 301 https://$server_name$request_uri;
    }
}

server {
    listen 443 ssl http2 default_server;
    #listen 443 ssl default_server;

    server_name solusar.de www.solusar.de;
    
    access_log /var/log/nginx/default-access.log;
    error_log /var/log/nginx/default-error.log;

    #ssl on;
    ssl_certificate /etc/letsencrypt/live/www.solusar.de/fullchain.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/www.solusar.de/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.solusar.de/privkey.pem;


    #ssl_dhparam /etc/myssl/dh4096.pem;
    #ssl_protocols TLSv1.2;
    #ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK';
    #ssl_session_timeout 5m;
    #ssl_prefer_server_ciphers on;
    #ssl_session_cache shared:SSL:50m;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header Content-Security-Policy "default-src 'none'; child-src 'self'; connect-src 'self'; img-src 'self' data: https: *.gravatar.com; script-src 'self' 'unsafe-eval' 'unsafe-inline' cdn.jsdelivr.net api.instagram.com pagead2.googlesyndication.com; style-src 'self' 'unsafe-inline' https: fonts.googleapis.com; font-src 'self' data: https: fonts.googleapis.com themes.googleusercontent.com; frame-ancestors 'self'; base-uri 'self'; form-action 'self' www.paypal.com; media-src https:;";

    #limit_req zone=one burst=10;

    root /var/www/vhosts/solusar.de/httpdocs;
    index index.php;

    include global/restrictions.conf;
    include global/php.conf;

    location / {
        # This is cool because no php is touched for static content.
        # include the "$is_args$args" so non-default permalinks doesn't break when using query string
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }
    
    #location ~ \.php$ {
    #    try_files $uri =404;
    #    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #    fastcgi_pass unix:/run/php/php8.0-fpm.sock;
    #    fastcgi_index index.php;
    #    include fastcgi_params;
    #}

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

}
