server {
    listen 80;
    server_name fidem-slonim.by www.fidem-slonim.by;
    
    root /home/fidemsloni/public_html;
    index index.html;
    
    # Security headers
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
    add_header X-XSS-Protection "1; mode=block";
    
    # Main location
    location / {
        try_files $uri $uri/ =404;
    }
    
    # Cache static files
    location ~* \.(css|js|png|jpg|jpeg|gif|svg|webp|woff|woff2|ttf|otf)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
    
    # Image optimization
    location ~* \.(jpg|jpeg|png|gif|svg|webp)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
        add_header Vary "Accept-Encoding";
    }
    
    # WebP support with proper Content-Type
    location ~* \.webp$ {
        add_header Content-Type "image/webp";
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
    
    # Gzip compression
    gzip on;
    gzip_types text/css application/javascript image/svg+xml application/json text/plain;
    gzip_min_length 1000;
    gzip_vary on;
}
