Files
khb_microservices/deploy/infra/services.nginx.conf
2026-11-16 22:19:06 +03:00

66 lines
3.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# services.khbuild.freeddns.org: общий хост публичных входов сервисов khb_microservices, по пути /api/<сервис>/.
# Один сертификат (khbuild-services) на все сервисы; новый сервис = новый location ниже, без нового сертификата.
# Наружу открывать только то, что должно быть публичным (вебхуки, MCP); внутренний REST остаётся в docker-сети.
server {
listen 80;
listen [::]:80;
server_name services.khbuild.freeddns.org;
location ^~ /.well-known/acme-challenge/ { root /var/www/certbot; }
location / { return 301 https://$host$request_uri; }
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name services.khbuild.freeddns.org;
ssl_certificate /etc/letsencrypt/live/khbuild-services/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/khbuild-services/privkey.pem;
client_max_body_size 1m;
# --- todo_service (khb-todo-service, 127.0.0.1:8094): вебхуки JobTread, MCP, metadata защищённого ресурса
location ^~ /api/todo/webhooks/jobtread/ {
rewrite ^/api/todo/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8094;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 30;
}
location = /api/todo/mcp {
rewrite ^/api/todo/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8094;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Authorization $http_authorization;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 120;
}
# metadata защищённого ресурса: и по пути сервиса, и в корне по схеме RFC 9728 (/.well-known/oauth-protected-resource/<путь ресурса>)
location = /api/todo/.well-known/oauth-protected-resource {
proxy_pass http://127.0.0.1:8094/.well-known/oauth-protected-resource;
proxy_set_header Host $host;
}
location = /.well-known/oauth-protected-resource/api/todo/mcp {
proxy_pass http://127.0.0.1:8094/.well-known/oauth-protected-resource;
proxy_set_header Host $host;
}
# --- qbo_auth (khb-qbo-auth, 127.0.0.1:8095): только возврат OAuth с Intuit; служебные ручки (/connect, /token, /status) наружу не открыты
location = /api/qbo/callback {
proxy_pass http://127.0.0.1:8095/callback$is_args$args;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 30;
}
location / { return 404; }
}