From 79c31d6d220bc5a57797d6d240c28f69ef066636 Mon Sep 17 00:00:00 2001 From: jedi Date: Wed, 22 Nov 2023 22:37:56 +0100 Subject: [PATCH] disable http auth for websockets --- core/notify_sessions/routing.py | 2 +- deploy/ansible/playbooks/templates/nginx.conf.j2 | 8 ++++++++ web/src/App.vue | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/notify_sessions/routing.py b/core/notify_sessions/routing.py index 45e7428..fdd4e97 100644 --- a/core/notify_sessions/routing.py +++ b/core/notify_sessions/routing.py @@ -3,6 +3,6 @@ from django.urls import path from .consumers import NotifyConsumer websocket_urlpatterns = [ - path('notify//', NotifyConsumer.as_asgi()), + path('ws/notify//', NotifyConsumer.as_asgi()), ] diff --git a/deploy/ansible/playbooks/templates/nginx.conf.j2 b/deploy/ansible/playbooks/templates/nginx.conf.j2 index 154aaf9..652eb84 100644 --- a/deploy/ansible/playbooks/templates/nginx.conf.j2 +++ b/deploy/ansible/playbooks/templates/nginx.conf.j2 @@ -24,6 +24,14 @@ server { try_files $uri $uri/ /index.html; } + location /ws { + proxy_http_version 1.1; + auth_basic off; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://c3lf-sys3; + } + location /api { proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/web/src/App.vue b/web/src/App.vue index 9f3cb9a..72309a6 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -35,7 +35,7 @@ export default { } }, created: function () { - this.notify_socket = new WebSocket('wss://' + window.location.host + '/notify/'); + this.notify_socket = new WebSocket('wss://' + window.location.host + '/ws/notify/'); this.notify_socket.onmessage = (e) => { let data = JSON.parse(e.data); console.log(data, e.data);