diff --git a/ansible_ai_connect/main/settings/base.py b/ansible_ai_connect/main/settings/base.py index 55515eef3..4b9e3ac86 100644 --- a/ansible_ai_connect/main/settings/base.py +++ b/ansible_ai_connect/main/settings/base.py @@ -94,6 +94,11 @@ "csp.middleware.CSPMiddleware", ] +if os.environ.get("CSRF_TRUSTED_ORIGINS"): + CSRF_TRUSTED_ORIGINS = os.environ.get("CSRF_TRUSTED_ORIGINS").split(",") +else: + CSRF_TRUSTED_ORIGINS = ["http://localhost:8000"] + # Allow Prometheus to scrape metrics ALLOWED_CIDR_NETS = [os.environ.get("ALLOWED_CIDR_NETS", "10.0.0.0/8")] diff --git a/tools/configs/nginx-wisdom.conf b/tools/configs/nginx-wisdom.conf index 3f8327679..1045b73c3 100644 --- a/tools/configs/nginx-wisdom.conf +++ b/tools/configs/nginx-wisdom.conf @@ -2,6 +2,12 @@ upstream uwsgi { server unix:///var/run/uwsgi/ansible_wisdom.sock; } +upstream daphne { +# server unix:///var/run/daphne/ansible_wisdom.sock; + server 127.0.0.1:9001; +} + + server { listen 8000 default_server; server_name _; @@ -14,4 +20,12 @@ server { uwsgi_pass uwsgi; include /etc/nginx/uwsgi_params; } + + location /api/v1/ai/streaming_chat/ { + proxy_pass http://daphne; + proxy_http_version 1.1; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_redirect off; + } } diff --git a/tools/configs/supervisord.conf b/tools/configs/supervisord.conf index 05a897e5d..622571191 100644 --- a/tools/configs/supervisord.conf +++ b/tools/configs/supervisord.conf @@ -28,6 +28,20 @@ stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 +[program:daphne] +; command = /var/www/venv/bin/daphne -u /var/run/daphne/ansible-wisdom.sock ansible_ai_connect.main.asgi:application +command = /var/www/venv/bin/daphne -b 0.0.0.0 -p 9001 ansible_ai_connect.main.asgi:application +autostart = true +autorestart = true +stopwaitsecs = 1 +stopsignal = KILL +stopasgroup = true +killasgroup = true +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 +stderr_logfile = /dev/stderr +stderr_logfile_maxbytes = 0 + ; [program:test] ; command = sleep infinity diff --git a/wisdom-service.Containerfile b/wisdom-service.Containerfile index 9d20acbf9..88cd80c44 100644 --- a/wisdom-service.Containerfile +++ b/wisdom-service.Containerfile @@ -50,7 +50,7 @@ RUN /var/www/venv/bin/python3.11 -m pip --no-cache-dir install --no-binary=all c RUN /var/www/venv/bin/python3.11 -m pip --no-cache-dir install -r/var/www/ansible-ai-connect-service/requirements.txt RUN /var/www/venv/bin/python3.11 -m pip --no-cache-dir install -e/var/www/ansible-ai-connect-service/ -RUN mkdir /var/run/uwsgi +RUN mkdir /var/run/uwsgi /var/run/daphne RUN echo -e "\ {\n\ @@ -99,6 +99,7 @@ RUN for dir in \ /var/log/supervisor \ /var/run/supervisor \ /var/run/uwsgi \ + /var/run/daphne \ /var/www/wisdom \ /var/log/nginx \ /etc/ari \