#!/bin/bash
# Simple Nginx Fix Script
# Fixes nginx.conf syntax error

cat > /tmp/nginx.conf.fix <<'EOF'
user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    
    sendfile on;
    keepalive_timeout 65;
    
    server {
        listen 80;
        server_name _;
        
        location /health {
            return 200 "healthy\n";
            add_header Content-Type text/plain;
        }
        
        location / {
            return 200 "Nginx Proxy - Phase 1\n";
            add_header Content-Type text/plain;
        }
    }
}
EOF

sudo cp /tmp/nginx.conf.fix /etc/nginx/nginx.conf
sudo nginx -t && sudo systemctl start nginx && sudo systemctl enable nginx && echo "Nginx fixed!" || echo "Nginx fix failed"

