# Nginx vhost for aibitadmin.aibitsoft.cloud – proxy to Node.js on port 4001
# Install: sudo cp nginx-aibitadmin.conf /etc/nginx/conf.d/aibitadmin.aibitsoft.cloud.conf && sudo nginx -t && sudo systemctl reload nginx

server {
    listen 80;
    server_name aibitadmin.aibitsoft.cloud www.aibitadmin.aibitsoft.cloud;

    root /dev/null;
    index index.html;
    autoindex off;

    location ^~ /.well-known/ {
        alias /home/aibitsofts/public_html/aibitadmin.aibitsoft.cloud/.well-known/;
        allow all;
    }

    location / {
        proxy_pass http://127.0.0.1:4001;
        proxy_http_version 1.1;
        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 Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_cache_bypass $http_upgrade;
    }
}

server {
    listen 443 ssl http2;
    server_name aibitadmin.aibitsoft.cloud www.aibitadmin.aibitsoft.cloud;

    ssl_certificate     /var/cpanel/ssl/apache_tls/aibitadmin.aibitsoft.cloud/combined;
    ssl_certificate_key /var/cpanel/ssl/apache_tls/aibitadmin.aibitsoft.cloud/combined;

    root /dev/null;
    index index.html;
    autoindex off;

    location ^~ /.well-known/ {
        alias /home/aibitsofts/public_html/aibitadmin.aibitsoft.cloud/.well-known/;
        allow all;
    }

    location / {
        proxy_pass http://127.0.0.1:4001;
        proxy_http_version 1.1;
        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 https;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_cache_bypass $http_upgrade;
    }
}
