From b0fb8e204ccffb4b18428d96b091c3ad49a8a45c Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Wed, 5 Feb 2025 16:59:50 +0100 Subject: [PATCH] fix: moved ws to api/v1/ws --- backend/bec_atlas/router/redis_router.py | 2 +- backend/utils/nginx.conf | 59 ++++--------------- .../src/app/core/redis-connector.service.ts | 1 + .../src/app/server-settings.service.ts | 6 +- 4 files changed, 17 insertions(+), 51 deletions(-) diff --git a/backend/bec_atlas/router/redis_router.py b/backend/bec_atlas/router/redis_router.py index 4f5a8ab..2a14504 100644 --- a/backend/bec_atlas/router/redis_router.py +++ b/backend/bec_atlas/router/redis_router.py @@ -279,7 +279,7 @@ class RedisWebsocket: redis_options={"username": "ingestor", "password": redis_password}, ), ) - self.app = socketio.ASGIApp(self.socket) + self.app = socketio.ASGIApp(self.socket, socketio_path=f"{prefix}/ws") self.loop = asyncio.get_event_loop() self.users = {} diff --git a/backend/utils/nginx.conf b/backend/utils/nginx.conf index c0c920f..bea845c 100644 --- a/backend/utils/nginx.conf +++ b/backend/utils/nginx.conf @@ -14,8 +14,8 @@ events { http { - # include mime.types; - default_type application/octet-stream; + #include mime.types; + #default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' @@ -38,14 +38,22 @@ http { #gzip on; server { listen 80; - server_name yourdomain.com; # Replace with your domain or IP + listen [::]:80 default_server; + server_name bec-atlas.psi.ch; # Replace with your domain or IP + root /var/nginx/bec-atlas-build/browser; + index index.html index.htm; # Configure SSL if needed # listen 443 ssl; # ssl_certificate /path/to/cert.pem; # ssl_certificate_key /path/to/key.pem; + # serve the angular frontend location / { + try_files $uri $uri/ /index.html; + } + + location /api { proxy_pass http://fastapi_backend; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -58,57 +66,12 @@ http { proxy_set_header Connection "upgrade"; } - location /nginx_status { - stub_status on; - access_log off; - allow 127.0.0.1; # Allow localhost - deny all; # Deny all others - } - - # Optional: Serve static files - location /static/ { - root /path/to/static/files; # Adjust the path - } - # Optional: Add caching for static files location ~* \.(jpg|jpeg|png|gif|css|js|ico|svg|woff|woff2|ttf|otf|eot|ttf|otf|html)$ { expires 30d; access_log off; } } - # another virtual host using mix of IP-, name-, and port-based configuration - # - #server { - # listen 8000; - # listen somename:8080; - # server_name somename alias another.alias; - # location / { - # root html; - # index index.html index.htm; - # } - #} - - - # HTTPS server - # - #server { - # listen 443 ssl; - # server_name localhost; - - # ssl_certificate cert.pem; - # ssl_certificate_key cert.key; - - # ssl_session_cache shared:SSL:1m; - # ssl_session_timeout 5m; - - # ssl_ciphers HIGH:!aNULL:!MD5; - # ssl_prefer_server_ciphers on; - - # location / { - # root html; - # index index.html index.htm; - # } - #} include servers/*; } diff --git a/frontend/bec_atlas/src/app/core/redis-connector.service.ts b/frontend/bec_atlas/src/app/core/redis-connector.service.ts index ca77845..e9dc54f 100644 --- a/frontend/bec_atlas/src/app/core/redis-connector.service.ts +++ b/frontend/bec_atlas/src/app/core/redis-connector.service.ts @@ -26,6 +26,7 @@ export class RedisConnectorService { autoConnect: true, // Automatically connect reconnection: true, // Enable automatic reconnection timeout: 500, // Connection timeout in milliseconds + path: '/api/v1/ws', // Path to the WebSocket server auth: { user: 'john_doe', token: '1234', diff --git a/frontend/bec_atlas/src/app/server-settings.service.ts b/frontend/bec_atlas/src/app/server-settings.service.ts index 051b695..6a3764f 100644 --- a/frontend/bec_atlas/src/app/server-settings.service.ts +++ b/frontend/bec_atlas/src/app/server-settings.service.ts @@ -9,11 +9,13 @@ export class ServerSettingsService { getServerAddress() { return ( - this.appConfigService.getConfig().baseUrl ?? 'http://localhost/api/v1/' + this.appConfigService.getConfig().baseUrl ?? 'http://localhost/api/v1' ); } getSocketAddress() { - return this.appConfigService.getConfig().wsUrl ?? 'http://localhost/'; + let out = this.appConfigService.getConfig().wsUrl ?? 'http://localhost'; + console.log(out); + return out; } }