Logo

nginxAppConfig

server {
    listen 80;
    server_name barryonweb.com;

    # Proxy settings for Backend API
    location /api/ {
        proxy_pass http://localhost:5000/;
        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 settings for WebSockets
    location /websocket {
        proxy_pass http://localhost:5000/websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }

    # Serve Frontend React App
    root /var/www/appRootNginx/clientDir;
    index index.html;

    location / {
        # Try to serve files directly, fallback to index.html for SPA routing
        try_files $uri /index.html;
    }

    # Logging
    access_log /var/log/nginx/appNginx-access.log;
    error_log /var/log/nginx/appNginx-error.log;
}