mirror of
https://github.com/itme-brain/nixos.git
synced 2026-05-08 06:50:11 -04:00
cors
This commit is contained in:
parent
f42ec1f725
commit
89768a9e0b
2 changed files with 26 additions and 1 deletions
|
|
@ -78,6 +78,14 @@ in
|
||||||
recommendedGzipSettings = true;
|
recommendedGzipSettings = true;
|
||||||
eventsConfig = "worker_connections 4096;";
|
eventsConfig = "worker_connections 4096;";
|
||||||
|
|
||||||
|
# CORS origin allowlist for MCP servers
|
||||||
|
commonHttpConfig = ''
|
||||||
|
map $http_origin $mcp_cors_origin {
|
||||||
|
default "";
|
||||||
|
"https://ai.${domain}" "https://ai.${domain}";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
# Catch-all default - friendly error for unknown subdomains
|
# Catch-all default - friendly error for unknown subdomains
|
||||||
virtualHosts."_" = {
|
virtualHosts."_" = {
|
||||||
default = true;
|
default = true;
|
||||||
|
|
@ -148,6 +156,23 @@ in
|
||||||
proxyWebsockets = true;
|
proxyWebsockets = true;
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
include ${config.sops.templates."nginx-mcp-auth.conf".path};
|
include ${config.sops.templates."nginx-mcp-auth.conf".path};
|
||||||
|
|
||||||
|
# CORS — $mcp_cors_origin is set by the http-level map
|
||||||
|
# and is empty for disallowed origins
|
||||||
|
if ($request_method = OPTIONS) {
|
||||||
|
add_header Access-Control-Allow-Origin $mcp_cors_origin always;
|
||||||
|
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
|
||||||
|
add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-API-Key" always;
|
||||||
|
add_header Access-Control-Allow-Credentials "true" always;
|
||||||
|
add_header Access-Control-Max-Age 86400 always;
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_header Access-Control-Allow-Origin $mcp_cors_origin always;
|
||||||
|
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
|
||||||
|
add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-API-Key" always;
|
||||||
|
add_header Access-Control-Allow-Credentials "true" always;
|
||||||
|
|
||||||
proxy_read_timeout 300s;
|
proxy_read_timeout 300s;
|
||||||
proxy_send_timeout 300s;
|
proxy_send_timeout 300s;
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
nginx = {
|
nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
sandpack.enable = true;
|
sandpack.enable = false;
|
||||||
forgejo.enable = true;
|
forgejo.enable = true;
|
||||||
frigate.enable = true;
|
frigate.enable = true;
|
||||||
immich.enable = true;
|
immich.enable = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue