# Template Nginx pour Octave FO (front-office). Placeholders : __DOMAIN__, __DOCUMENT_ROOT__
# Généré par install_octave.sh (menu « Créer un site nginx pour un domaine FO »).
# Certificat SSL : Certbot ajoute redirection HTTP→HTTPS et bloc 443 (menu « Installer certificat Let's Encrypt » ou certbot --nginx -d __DOMAIN__).

server {
    listen 80;
    listen [::]:80;
    server_name __DOMAIN__;
    server_tokens off;

    root __DOCUMENT_ROOT__;
    index index.html index.htm index.php;
    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;
    add_header Referrer-Policy "strict-origin-when-cross-origin";
    # CSP FO : unpkg (Leaflet, Dropzone + source maps), bugherd; Google/Bunny fonts; jsdelivr (bootstrap-icons); tile OSM, CDN, objectstorage; iframe Mozart Prestige
    add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://unpkg.com https://www.bugherd.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://cdn.jsdelivr.net https://unpkg.com https://fonts.bunny.net; img-src 'self' data: blob: https://tile.openstreetmap.org https://*.octave.immo https://cdn.octave.immo https://cdn.mozartdigital.fr https://*.your-objectstorage.com https://*.s3.gra.io.cloud.ovh.net https://*.s3.eu-west-par.io.cloud.ovh.net; font-src 'self' https://fonts.gstatic.com https://fonts.bunny.net https://cdn.jsdelivr.net; connect-src 'self' https://www.bugherd.com https://unpkg.com; frame-src 'self' blob: data: https://www.mozartprestigepatrimoine.fr https://location-insight.cityscan.fr; 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/__DOMAIN__-access.log;
    error_log  /var/log/nginx/__DOMAIN__-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;
    }
}
