Proxy Hesychia finance webhooks to chat_backend so Stripe POST is not 405.
Sync runner checkout / sync (pull_request) Successful in 7s
Sync runner checkout / sync (pull_request) Successful in 7s
The static SPA nginx served index.html for /api/finance/webhooks/stripe/ and rejected the method. Closes #41.
This commit is contained in:
1 parent
7f570b40a2
commit
f24e1d3305
3 files changed
+40
No files matched your search
@@ -119,6 +119,10 @@ app_catalog:
|
|||||||
# Document root served by nginx and written by `npm run build:<env>`.
|
# Document root served by nginx and written by `npm run build:<env>`.
|
||||||
# {env} is replaced with the entry's env (beta/prod).
|
# {env} is replaced with the entry's env (beta/prod).
|
||||||
webroot_pattern: "/var/www/{env}.chat.aimloperations/html"
|
webroot_pattern: "/var/www/{env}.chat.aimloperations/html"
|
||||||
|
# hesychia.ai Stripe/RevenueCat webhooks hit this vhost. Proxy the prefix
|
||||||
|
# to chat_backend so POST is not answered 405 by the SPA index.html.
|
||||||
|
api_backend: chat_backend
|
||||||
|
api_proxy_prefix: /api/finance/webhooks/
|
||||||
chat_backend:
|
chat_backend:
|
||||||
type: django
|
type: django
|
||||||
repo: "{{ git_base_url }}/ai_ml_operations/chat_backend.git"
|
repo: "{{ git_base_url }}/ai_ml_operations/chat_backend.git"
|
||||||
@@ -126,6 +130,11 @@ app_catalog:
|
|||||||
compose_file: docker-compose.prod.yml
|
compose_file: docker-compose.prod.yml
|
||||||
web_service: web
|
web_service: web
|
||||||
migrate_cmd: "uv run python manage.py migrate --noinput"
|
migrate_cmd: "uv run python manage.py migrate --noinput"
|
||||||
|
# Host header the static-site webhook proxy sends. Must be in Django
|
||||||
|
# ALLOWED_HOSTS (see chat_backend DJANGO_ALLOWED_HOSTS).
|
||||||
|
public_hosts:
|
||||||
|
prod: chatbackend.aimloperations.com
|
||||||
|
beta: beta.chatbackend.aimloperations.com
|
||||||
monica_site:
|
monica_site:
|
||||||
type: django
|
type: django
|
||||||
repo: "{{ git_base_url }}/ai_ml_operations/monica_site.git"
|
repo: "{{ git_base_url }}/ai_ml_operations/monica_site.git"
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ services:
|
|||||||
web-static:
|
web-static:
|
||||||
image: {{ web_static_image }}
|
image: {{ web_static_image }}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
# Webhook locations proxy to chat_backend on the host-published port.
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
logging:
|
logging:
|
||||||
driver: json-file
|
driver: json-file
|
||||||
options:
|
options:
|
||||||
|
|||||||
@@ -30,6 +30,34 @@ server {
|
|||||||
root {{ (app_catalog[a.name].webroot_pattern | default(web_static_root ~ '/{env}_' ~ a.name)) | replace('{env}', a.env) }};
|
root {{ (app_catalog[a.name].webroot_pattern | default(web_static_root ~ '/{env}_' ~ a.name)) | replace('{env}', a.env) }};
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
|
{%- set api_backend_name = app_catalog[a.name].api_backend | default('') %}
|
||||||
|
{%- if api_backend_name %}
|
||||||
|
{%- set api_proxy_prefix = app_catalog[a.name].api_proxy_prefix | default('/api/') %}
|
||||||
|
{%- set api_match = namespace(port=0, ok=false) %}
|
||||||
|
{%- for item in host_apps | default([]) %}
|
||||||
|
{%- if item.name == api_backend_name and item.env == a.env and (item.enabled | default(true)) %}
|
||||||
|
{%- set api_match.port = item.port %}
|
||||||
|
{%- set api_match.ok = true %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- if api_match.ok %}
|
||||||
|
{%- set api_host = (app_catalog[api_backend_name].public_hosts | default({}))[a.env] | default('') %}
|
||||||
|
|
||||||
|
# Finance webhooks (Stripe) arrive on the public product host. The SPA
|
||||||
|
# try_files fallback is a static file and returns 405 for POST.
|
||||||
|
location {{ api_proxy_prefix }} {
|
||||||
|
proxy_pass http://host.docker.internal:{{ api_match.port }};
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host {{ api_host if api_host else '$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;
|
||||||
|
proxy_read_timeout 60s;
|
||||||
|
client_max_body_size 2m;
|
||||||
|
}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{% if app_catalog[a.name].error_page_404 | default('') %}
|
{% if app_catalog[a.name].error_page_404 | default('') %}
|
||||||
error_page 404 {{ app_catalog[a.name].error_page_404 }};
|
error_page 404 {{ app_catalog[a.name].error_page_404 }};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user