# Template Nginx pour Octave BO préprod (preprod.octave.immo). Placeholder : __DOCUMENT_ROOT__
# Généré par install_octave.sh (NGINX_SITE=preprod.octave.immo). Pas de WordPress sur la préprod.

server {
    listen 80;
    listen [::]:80;
    server_name preprod.octave.immo;
    server_tokens off;

    root __DOCUMENT_ROOT__;
    index index.php index.html;
    charset utf-8;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    # CSP BO : jquery, jsdelivr (bootstrap, sortablejs), quilljs; cdnjs (page 429); lightbox PDF (frame blob/data); img objectstorage; connect unpkg (source maps)
    add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://code.jquery.com https://cdn.jsdelivr.net https://cdn.quilljs.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdn.quilljs.com https://cdnjs.cloudflare.com; img-src 'self' data: blob: https://*.your-objectstorage.com https://*.s3.gra.io.cloud.ovh.net https://*.s3.eu-west-par.io.cloud.ovh.net; font-src 'self' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com; connect-src 'self' https://unpkg.com https://cdn.jsdelivr.net; frame-src 'self' blob: data:; frame-ancestors 'self'; base-uri 'self'; object-src 'none'; upgrade-insecure-requests;" always;

    client_max_body_size 100M;

    # ModSecurity v3 (ngx_http_modsecurity_module)
    modsecurity on;
    modsecurity_rules_file /etc/nginx/modsecurity/modsecurity-octave.conf;

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

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

    access_log /var/log/nginx/octave-access.log;
    error_log  /var/log/nginx/octave-error.log error;
    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php8.5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS $http_x_forwarded_proto;
        fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto;
        fastcgi_param HTTP_X_FORWARDED_HOST $http_host;
        fastcgi_param HTTP_X_FORWARDED_PORT $http_x_forwarded_port;
        fastcgi_read_timeout 300;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}
