WSS via Nginx/443 shows 127.0.0.1 and bypasses Fail2Ban

Dear Team,

I would like to report an issue/concern regarding SIP WebSocket (WSS) registrations through the Nginx reverse proxy.

I have observed the following behavior on VitalPBX system:

1. Direct WSS connection on port 8089

When an extension registers using:

wss://mydomain.com:8089/ws

the registration/contact information shows the actual public IP address of the client device.

If incorrect SIP credentials are repeatedly submitted from this client, Fail2Ban is able to identify and block the client’s public IP as expected.

2. WSS connection through Nginx on port 443

When the same extension registers using:

wss://mydomain.com/ws

which is reverse-proxied by Nginx to Asterisk on 127.0.0.1:8088, the registration/contact information shows:

127.0.0.1

instead of the actual public IP address of the client.

More importantly, I tested this with intentionally incorrect SIP credentials. When multiple unauthorized registration attempts are made through the /ws endpoint on port 443, the client’s public IP is not blocked by Fail2Ban.

It appears that, because the WebSocket connection is reverse-proxied through Nginx, Asterisk/PJSIP is seeing the connection as originating from 127.0.0.1. Since 127.0.0.1 is trusted/whitelisted by Fail2Ban, the original public IP cannot be blocked by the existing Fail2Ban protection.

For reference, my Nginx /ws configuration is:

location /ws {
    proxy_pass http://127.0.0.1:8088/ws;
    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-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

Could you please confirm:

  1. Is this expected behavior for the VitalPBX WSS reverse-proxy implementation?

  2. Is there a supported configuration that allows Asterisk/PJSIP and its security/Fail2Ban mechanism to retain the original client’s public IP when registering through /ws on port 443?

  3. If the original IP cannot be passed to PJSIP through the reverse proxy, how does VitalPBX recommend protecting the /ws endpoint against SIP registration brute-force attacks?

  4. Is this behavior addressed in the newer releases, particularly the changes related to custom HTTPS ports and reverse-proxied SIP WebSocket connections?

I would appreciate your guidance, as this is a security concern for any VitalPBX installation using the reverse-proxied WSS endpoint.

Regards,
Hemant

We encountered precisely this issue in production following the recent VitXi updates.

Our architecture deliberately restricts WebRTC devices to trusted corporate networks using PJSIP endpoint ACLs. Each VitXi user has a dedicated extension device with its own ACL restrictions. With direct WSS/8089, Asterisk sees the actual client IP, and those restrictions work as intended.

When VitXi began preferring NGINX/443 → 127.0.0.1:8088/ws, our VitXi devices stopped registering. We confirmed that Asterisk was rejecting the localhost source. Restoring functionality required adding 127.0.0.1/32 to the permitted addresses of each dedicated VitXi extension device.

We also confirmed that VitXi 4.6.0-11 (possibly earlier, we didn’t test) successfully falls back to direct WSS/8089 when we temporarily configured NGINX to return HTTP 503 for the /ws endpoint.

I appreciate the potential security advantages of placing Asterisk behind a reverse proxy, but this appears to shift source IP enforcement outside Asterisk while undermining existing PJSIP ACL and Fail2Ban protections. We currently mitigate this through restrictive firewall rules and NGINX access controls, but those are not equivalent to protection against SIP authentication abuse.

In principle, this architecture could be a positive step toward safely allowing external VitXi access from our perspective, particularly if coupled with centrally enforceable MFA. However, MFA must not be bypassable through direct SIP registration, and protecting the /ws endpoint against brute-force attacks using the actual originating client IP is essential. We would not consider external access without effective Fail2Ban protection or a demonstrably equivalent SIP-aware mechanism.

I’d appreciate VitalPBX clarifying the intended security architecture, how Fail2Ban should protect proxied SIP registrations, and whether there’s a supported configuration to explicitly select direct WSS rather than relying on fallback. We could find no such support in the GUI for either VitalPBX or the VitXi configurations.

Hi,

Work around for this security issue is by commenting the following under Nginx

Go to
nano /etc/nginx/sites-available/vitalpbx
and comment location /ws that is

location /ws {
proxy_pass http://127.0.0.1:8088/ws;
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-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

save and exit the file
Run
nginx -t
followed by
systemctl reload nginx

Thanks so much …This workaround is work.
we will be waiting for vitalpbx developers and support team to implement that in the next update or fix it permanently to avoid removing the modification after version update. @miguel @maynor

This get covered in the latest VitalPBX update!