diff --git a/deploy/nginx/dev.conf b/deploy/nginx/dev.conf index 6eb39ef9..5c5fdc81 100644 --- a/deploy/nginx/dev.conf +++ b/deploy/nginx/dev.conf @@ -23,6 +23,16 @@ server { alias /usr/src/app/media; } + location /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-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://app_server; + } + location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; diff --git a/deploy/nginx/prod.conf b/deploy/nginx/prod.conf index a4c7fea8..77dd3c85 100644 --- a/deploy/nginx/prod.conf +++ b/deploy/nginx/prod.conf @@ -87,6 +87,16 @@ server { proxy_redirect http://reporter:5129/ /reporter/; } + location /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-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://app_server; + } + # Default proxy to the Django/gunicorn upstream location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -124,6 +134,16 @@ server { location /static/ { alias /usr/src/app/static/; } location /media { alias /usr/src/app/media; } + location /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-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://app_server; + } + location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; diff --git a/generic/models.py b/generic/models.py index e01b5ffc..a76db4be 100644 --- a/generic/models.py +++ b/generic/models.py @@ -323,7 +323,7 @@ class SeriesImageBase(models.Model): try: with pydicom.dcmread(self.image) as d: return d - except pydicom.errors.InvalidDicomError: + except (pydicom.errors.InvalidDicomError, FileNotFoundError, OSError): return {} def get_full_url(self): @@ -335,14 +335,14 @@ class SeriesImageBase(models.Model): def get_dicom_json(self): try: json = pydicom.dcmread(self.image).to_json() - except pydicom.errors.InvalidDicomError: + except (pydicom.errors.InvalidDicomError, FileNotFoundError, OSError): return {} return json def get_dicom_info(self): try: info = pretty_print_dicom(pydicom.dcmread(self.image)) - except pydicom.errors.InvalidDicomError: + except (pydicom.errors.InvalidDicomError, FileNotFoundError, OSError): info = "File is not a dicom." return info diff --git a/generic/routing.py b/generic/routing.py index 4a4d08b1..2f9fce66 100644 --- a/generic/routing.py +++ b/generic/routing.py @@ -2,5 +2,5 @@ from django.urls import re_path from . import consumers websocket_urlpatterns = [ - re_path(r'^ws/multiuser/(?P[\w-]+)/$', consumers.MultiuserConsumer.as_asgi()), + re_path(r'^/ws/multiuser/(?P[\w-]+)/$', consumers.MultiuserConsumer.as_asgi()), ]