[SOLVED] Docker Mattermost / NGINX Websocket Error 400

I have a docker mattermost running and it works perfectly when opened directly through server IP and Docker mapped port (192.168.0.5:33000) Everything works great.

The problem is when I try to make it work through NGINX proxy. The website itself works, I can login and go into channels and everything, but when typing a message I get:

WebSocket connection to ‘wss://chat.spntt.com/api/v3/users/websocket’ failed: Error during WebSocket handshake: Unexpected response code: 400, and I get the “Please check connection, Mattermost unreachable, if issue persists, ask administrator to check WebSocket port.”

And this repeats for every message typed in chat. I tried adding additional nginx rules as below but is still does not work.

location /api/v3/ {
proxy_pass http://192.168.0.5:33000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $host;
}

Fixed by adding ^~

location ^~ /api/v3/ {
proxy_pass http://192.168.0.5:33000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $host;
}

Glad to hear your issue is resolved @BobTB!

Hi @BobTB is this configuration working? I’ve added to my main server NGINX file and the websocket connection keeps failing.

Maybe you could help me: WebSocket not working on Server behind reverse proxy

The above mentioned configuration also is missing the websocket specific locations. Please check out the official documentation on how to set up the nginx proxy:

https://docs.mattermost.com/install/config-proxy-nginx.html