📄 gcp_nginx.conf
/home/palash/git/local-ai/gcp_nginx.conf
Language: conf • Lines: 78
server {
    listen 80;
    server_name home.palashkantikundu.in;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name home.palashkantikundu.in;

    ssl_certificate     /etc/nginx/ssl/home.palashkantikundu.in/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/home.palashkantikundu.in/privkey.pem;

    # --- ENABLE GZIP HERE ---
    gzip on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_min_length 256;
    gzip_types
        application/javascript
        application/json
        application/xml
        text/css
        text/javascript
        text/plain
        text/xml;
    # ------------------------

    # Intercept errors from home server connection
    proxy_intercept_errors on;
    error_page 502 503 504 = @server_offline;

    # Inline HTML page served when main server is down
    location @server_offline {
        default_type text/html;
        return 502 '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Main Server Offline</title>
    <style>
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #0d1117; color: #c9d1d9; display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; }
        .card { background: #161b22; border: 1px solid #30363d; border-radius: 12px; padding: 32px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
        .icon { font-size: 48px; margin-bottom: 16px; }
        .title { font-size: 20px; font-weight: 600; color: #f85149; margin-bottom: 8px; }
        .desc { font-size: 14px; color: #8b949e; line-height: 1.5; }
    </style>
</head>
<body>
    <div class="card">
        <div class="icon">⚠️</div>
        <div class="title">Main Server Offline</div>
        <div class="desc">The home server is currently unreachable or powered off. Please try again later.</div>
    </div>
</body>
</html>';
    }

    location / {
            proxy_pass https://10.66.66.3;
            proxy_ssl_server_name on;
            proxy_ssl_verify off;

            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Via-GCP "true";

            # Fast failover timeouts
            proxy_connect_timeout 3s;
            proxy_read_timeout 5s;
            proxy_send_timeout 5s;
    }
}