How to add second location for subdomain

Discussion in 'Installation/Configuration' started by hostea, Apr 3, 2025.

  1. hostea

    hostea New Member

    I'm currently running a containerd analytics application on one of my ISPconfig servers which is working fine. The webinterface is proxied through nginx on a subdomain of a website running on the same server. Here my config:

    Subdomain:
    Host: stats
    Domain: example.com
    Redirect Type: Proxy
    Redirect Path: HTTP 10.11.12.13:9999
    Don't add to Let's Encrypt certificate: unchecked
    Active: checked

    Because the application requires several headers I set them in the options tab:

    Code:
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_redirect off;
    Now because the app requires a connection via websocket to itself I'd like to add a second location to the nginx config like so:

    Code:
        # WebSocket
        location /live/websocket {
            proxy_pass HTTP 10.11.12.13:9999;
            
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
    
            # Timeout
            proxy_read_timeout 3600s;
            proxy_send_timeout 3600s;
        }
    This works fine if I edit the nginx config under /etc/nginx/sites-available manualy but gets overwirtten everytime changes are made to the parent site in ISPconfig. How do I configure this in ISPConfig itself?

    Thanks for yor help.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Copy your location code into the nginx directives field on the options tab of the website.
     
  3. hostea

    hostea New Member

    I tried that but it didn't work.

    The websocket is part of the site on the subdomain and not the parent website:

    wss://stats.example.com/live/websocket?_csrf_token=CyUZOTsqZz4NHQk1WihdgfkjpoOpnZyhPlDgJX1maPPkQ4dOCw&_mounts=0&_live_referer=undefined&vsn=2.0.0
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Then, you should consider adding that subdomain as a separate website in ISPConfig instead of adding it as a subdomain (which is a vhost alias domain).
     

Share This Page