Skip to content

Commit

Permalink
Make /api/eda and /api/eda/v1 endpoints available via API service
Browse files Browse the repository at this point in the history
  • Loading branch information
rooftopcellist committed Jul 24, 2024
1 parent bff204a commit 77d8b1a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
22 changes: 16 additions & 6 deletions roles/eda/templates/eda-api.configmap.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,35 @@ data:
types {
application/manifest+json webmanifest;
}

# Define the upstream gunicorn server
upstream gunicorn {
server 127.0.0.1:{{ api_django_port }};
}

server {
listen {{ api_nginx_port }};
location ^~ /static/ {
location ^~ /api/eda/static/ {
alias {{ static_path }}/;
access_log /var/log/nginx/static_access.log;
error_log /var/log/nginx/static_error.log;
}
location ~ ^/api/eda {
proxy_pass http://gunicorn; # Forward requests to Django app
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
proxy_pass http://127.0.0.1:{{ api_django_port }}; # Forward requests to Django app
proxy_pass http://gunicorn; # Forward requests to Django app
proxy_set_header Host $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;
access_log /var/log/nginx/proxy_access.log;
error_log /var/log/nginx/proxy_error.log;
}
# Redirect trailing slash for eda root
location = /api/eda {
return 301 $scheme://$host/api/eda/;
}
}
}
15 changes: 3 additions & 12 deletions roles/eda/templates/eda.configmap.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ data:
EDA_WEBSOCKET_SSL_VERIFY: "{{ websocket_ssl_verify }}"
EDA_MAX_RUNNING_ACTIVATIONS: "12"

EDA_STATIC_URL: /api/eda/static/

# Custom user variables
{% for item in extra_settings | default([]) %}
{{ item.setting | upper }}: "{{ item.value }}"
Expand Down Expand Up @@ -75,21 +77,10 @@ data:

root /usr/share/nginx/html;

location ~ ^/api/eda/v[0-9]+/ {
proxy_pass http://{{ api_server_name }}:{{ api_nginx_port }};
proxy_set_header Origin http://{{ api_server_name }}:{{ api_nginx_port }};
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $remote_scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location ~ ^/static/ {
location ~ ^/api/eda {
proxy_pass http://{{ api_server_name }}:{{ api_nginx_port }};
proxy_set_header Origin http://{{ api_server_name }}:{{ api_nginx_port }};
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $remote_scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down

0 comments on commit 77d8b1a

Please sign in to comment.