Openlitespeed working Redirect rule

I have tried to convert the given nginx rule to openlitespeed rule. But it didn’t work,
Site is opening perfectly but I am getting this error Please check connection, Mattermost unreachable. If issue persists, ask administrator to [check WebSocket port]

upstream backend {
server {ip}:8065;
keepalive 32;
}

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;

server {
listen 80 default_server;
server_name mattermost.example.com;

location ~ /api/v[0-9]+/(users/)?websocket$ {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    client_max_body_size 50M;
    proxy_set_header Host $http_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_set_header X-Frame-Options SAMEORIGIN;
    proxy_buffers 256 16k;
    proxy_buffer_size 16k;
    client_body_timeout 60;
    send_timeout 300;
    lingering_timeout 5;
    proxy_connect_timeout 90;
    proxy_send_timeout 300;
    proxy_read_timeout 90s;
    proxy_pass http://backend;
}

location / {
    client_max_body_size 50M;
    proxy_set_header Connection "";
    proxy_set_header Host $http_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_set_header X-Frame-Options SAMEORIGIN;
    proxy_buffers 256 16k;
    proxy_buffer_size 16k;
    proxy_read_timeout 600s;
    proxy_cache mattermost_cache;
    proxy_cache_revalidate on;
    proxy_cache_min_uses 2;
    proxy_cache_use_stale timeout;
    proxy_cache_lock on;
    proxy_http_version 1.1;
    proxy_pass http://backend;
}

}

If anyone has working file, then Please send here.
I am trying to configure it in litespeed webserver.

Hi shivamkr and welcome to the Mattermost forums!

Can you please your work-in-progress OLS configuration?

1 Like

Yes, I am working on OLS Configuration currently, Yes work in progress, but unable to find any solution.

As I am wprking, On the IP:8065, Mattermost is running smoothly, but when I connect it with the subdomain, then showing error of " Please check connection, Mattermost unreachable. If issue persists, ask administrator to [check WebSocket port]."

Also I have Added added the “Web Socket Proxy” But I think there is error in web socket proxy.

It’s hard to tell without seeing your OLS configuration. Can you share it with us?

1 Like

I have been shared details to you.

I have solved this issue by adding these lines, I am sharing here the solution, it helps many people for to get rid out this similar issue.

I have added these lines in vhost file of the domain.

context / {
    location      $DOC_ROOT/
    allowBrowse     1
    extraHeaders   Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
  }
  context / {
    location        $DOC_ROOT/
    allowBrowse     1
    extraHeaders   X-Content-Type-Options nosniff
  }
  context / {
    location       $DOC_ROOT/
    allowBrowse    1
    extraHeaders    X-XSS-Protection 1;mode=block
  }
  context / {
    location    $DOC_ROOT/
    allowBrowse    1
    extraHeaders  X-Frame-Options SAMEORIGIN
  }
  context / {
    location      $DOC_ROOT/
    allowBrowse   1
    extraHeaders   Referrer-Policy strict-origin
  }
websocket /api {
  address                 127.0.0.1:8065
}

Thanks for posting this and sorry for not following up on that topic yesterday, got busy at work.
I’ve not much experience with OLS so far, but all those context / lines can probably be put into just one. According to some documentation I found it looks like you can just specify multiple headers line by line in the same context.

Also, according to this documentation the websocket regex could be carried over, too, because it’s not just /api, but a more specific subset of this URL:

context / {
    location      $DOC_ROOT/
    allowBrowse     1
    extraHeaders   Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
    extraHeaders   X-Content-Type-Options nosniff
    extraHeaders    X-XSS-Protection 1;mode=block
    extraHeaders  X-Frame-Options SAMEORIGIN
    extraHeaders   Referrer-Policy strict-origin
  }

websocket /api/v[0-9]+/(users/)?websocket$ {
  address                 127.0.0.1:8065
}

I think the really relevant part here was the websocket /api line, which might have been missing in your earlier configuration.

I am using hit and trial, that’t why it generated multiple context file.
Yes, Your given solution merge all contexts.
Earlier I am trying this method, I am getting the error, So I go with one-by-one testing and found the solution.