Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

6.0 KB
Raw Blame
# Running as non-root user will trigger warning.
# user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
# Running as non-root user will trigger warning
# for default /var/run/ prefix.
pid        /tmp/nginx.pid;

events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;
    server_tokens   off;
    keepalive_timeout  65;

    gzip  on;
    # nginx gzips only text/html by default; add asset types (~5-6x smaller).
    gzip_types text/css application/javascript application/json image/svg+xml;
    gzip_min_length 1024;
    gzip_vary on;
    # GKE LB adds a Via header; default gzip_proxied off would skip every request.
    gzip_proxied any;

    # Non-root user will not have access to default
    # /var/cache/nginx/ prefix.
    client_body_temp_path   /tmp/client_temp 1 2;
    proxy_temp_path         /tmp/proxy_temp 1 2;
    fastcgi_temp_path       /tmp/fastcgi_temp 1 2;
    uwsgi_temp_path         /tmp/uwsgi_temp 1 2;
    scgi_temp_path          /tmp/scgi_temp 1 2;

    # Cache policy by URL. Vite emits content-hashed filenames under /assets/,
    # so those bytes never change and can be cached forever; everything else
    # (index.html, runtime-config.js, SPA routes) must stay uncached so new
    # deploys are picked up. Driven from a single server-level add_header so it
    # composes with the security headers instead of overriding them (nginx does
    # not merge add_header across location/server scopes).
    map $uri $cache_control {
        default      "no-cache";
        ~^/assets/   "public, max-age=31536000, immutable";
    }

    server {
        listen 80;
        root  /usr/share/nginx/html;
        include /etc/nginx/mime.types;

        # Security headers
        add_header X-Content-Type-Options "nosniff" always;
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header Referrer-Policy "strict-origin-when-cross-origin" always;

        # CSP, enforcing: a resource from an origin no directive lists is blocked, not
        # reported. Re-check with .claude/skills/csp-check before a frontend dependency
        # starts loading from a new external host.
        # connect-src carries no `wss:` wildcard: socket.io connects to window.location.origin
        # (frontend/src/helpers/GetStaticData.js getBaseUrl), and 'self' covers same-origin
        # ws/wss per CSP3.
        # The Google analytics hosts are wildcarded because GA4 picks a regional collection
        # host at runtime, so the set is not enumerable. Signals/Ads endpoints
        # (*.g.doubleclick.net, www.google.com/g/collect) are deliberately not granted --
        # enabling either in the GTM UI needs a policy change here.
        # VITE_CUSTOM_LOGO_URL / VITE_FAVICON_PATH are governed by img-src: an absolute URL
        # to an unlisted host is blocked, and both fall back silently.
        add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.jsdelivr.net https://unpkg.com https://eu.i.posthog.com https://eu-assets.i.posthog.com https://*.googletagmanager.com https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/ https://js.stripe.com https://app.productfruits.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://app.productfruits.com; img-src 'self' data: blob: https://eu.i.posthog.com https://eu-assets.i.posthog.com https://cdn.jsdelivr.net https://app.productfruits.com https://cdn.productfruits.com https://*.googletagmanager.com https://*.google-analytics.com https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/ https://q.stripe.com; font-src 'self' data: https://cdn.jsdelivr.net https://app.productfruits.com https://cdn.productfruits.com; connect-src 'self' blob: https://cdn.jsdelivr.net https://unpkg.com https://eu.i.posthog.com https://eu-assets.i.posthog.com https://*.googletagmanager.com https://*.google-analytics.com https://analytics.google.com https://*.analytics.google.com https://www.google.com/recaptcha/ https://api.stripe.com https://m.stripe.network https://app.productfruits.com https://api.productfruits.com; frame-src 'self' https://www.google.com/recaptcha/ https://recaptcha.google.com https://*.googletagmanager.com https://js.stripe.com https://hooks.stripe.com https://m.stripe.network; media-src 'self' blob: https://cdn.productfruits.com; worker-src 'self' blob: https://unpkg.com https://cdn.jsdelivr.net; object-src 'none'; base-uri 'self'; form-action 'self' https://checkout.stripe.com; frame-ancestors 'self'" always;

        # Cache-Control from the $cache_control map (immutable for /assets/*,
        # no-cache otherwise). Declared at server scope alongside the security
        # headers so a location block does not have to redeclare add_header
        # (which would drop the inherited security headers).
        add_header Cache-Control $cache_control always;

        # Disable TRACE and TRACK methods
        if ($request_method ~ ^(TRACE|TRACK)$) {
            return 405;
        }

        # Content-hashed build output. No add_header here, so the server-level
        # security + cache headers are inherited. 404 (not the SPA fallback)
        # for a missing asset.
        location /assets/ {
            limit_except GET HEAD {
                deny all;
            }
            try_files $uri =404;
        }

        # If a react app URI is directly accessed we will get 404
        # since there will be no file representing that path.
        # Below config will load index.html file in such case and
        # browser will load the proper path using JS.
        location / {
            # Limit allowed HTTP methods
            limit_except GET HEAD {
                deny all;
            }
            try_files $uri /index.html;
        }

    }
}