Files
khb_microservices/deploy/infra/services.nginx.conf

99 lines
4.6 KiB
Plaintext
Raw Permalink 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;
}
# --- accounting_automation (khb-accounting, 127.0.0.1:8096): MCP для Claude сотрудников (разбор очереди бухгалтерии); внутренний REST наружу не открыт
location = /api/acc/mcp {
rewrite ^/api/acc/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8096;
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;
}
location = /api/acc/.well-known/oauth-protected-resource {
proxy_pass http://127.0.0.1:8096/.well-known/oauth-protected-resource;
proxy_set_header Host $host;
}
location = /.well-known/oauth-protected-resource/api/acc/mcp {
proxy_pass http://127.0.0.1:8096/.well-known/oauth-protected-resource;
proxy_set_header Host $host;
}
# --- acc_invoices (khb-acc-invoices, 127.0.0.1:8097): WebUI и API платёжного процесса (инвойсы и платежи) для сотрудников; вход по токену Keycloak/статическому
location = /invoices { return 301 /invoices/; }
location ^~ /invoices/ {
rewrite ^/invoices/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8097;
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 60;
}
location / { return 404; }
}