server {
    listen 9999 ssl;

    server_name ControlCenter5.0;

    ssl_certificate /etc/nginx/certs/nginx.crt;
    ssl_certificate_key /etc/nginx/certs/nginx.key;
    client_max_body_size 15M;
    gzip_static on;

    set $app_root /opt/artixcs-controlcenter-5;
    location = /CC5 {
        return 301 /CC5/;
    }
    # Long-term caching
    location /CC5/assets/ {
        add_header Cache-Control "public, max-age=31536000, immutable" always;
        alias $app_root/assets/;
    }
    # Translation hashes
    location = /CC5/locales/dist/language-hashes.json {
        add_header Cache-Control "no-store" always;
        alias $app_root/locales/dist/language-hashes.json;
    }
    # SPA entry point
    location = /CC5/index.html {
        add_header Set-Cookie $has_cookie;
        add_header Cache-Control "no-store" always;
        alias $app_root/index.html;
    }
    # Default
    location /CC5/ {
        add_header Cache-Control "no-cache" always;
        alias $app_root/;
        try_files $uri /CC5/index.html;
    }

    location /CC5/cash-config/ {
        proxy_pass http://127.0.0.1:8084/cash-config/;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Cc-Version "CC5";

        proxy_buffering off;
        proxy_connect_timeout 300;
        proxy_send_timeout 300;
        proxy_read_timeout 300;
    }

    location / {
        # PUT CASHSERVER REST ROUTING CONNECTION HERE;.
        proxy_pass http://127.0.0.1:8080/;

        # For auth
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Cc-Version "CC5";

        # WebSocket support
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        # For streaming response
        proxy_buffering off;
    }

}

