Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/scripts/allen/nginx-allen-location.conf # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / scripts / allen / nginx-allen-location.conf` 323 lines ยท 12993 bytes Raw Blame History 1 # /etc/nginx/snippets/aienos-allen.conf - included inside the www.aienos.com 2 # TLS server. Only the exact routes below reach the gateway; nothing under 3 # /allen/api/ is logged (no addresses, no paths). Requests that did not arrive 4 # through the PROXY-protocol listener (empty $proxy_protocol_addr) are refused, 5 # because nginx does not count empty limiter keys. 6 location ^~ /allen/api/ { 7 access_log off; 8 error_page 429 = @allen_rate; 9 limit_req_status 429; 10 limit_conn_status 429; 11 add_header Cache-Control "no-store" always; 12 add_header X-Content-Type-Options nosniff always; 13 add_header Strict-Transport-Security "max-age=`31536000`; includeSubDomains" always; 14 add_header Referrer-Policy no-referrer always; 15 add_header Content-Security-Policy "default-src 'none'; frame-ancestors 'none'" always; 16 17 location = /allen/api/chat { 18 if ($proxy_protocol_addr = "") { return 503; } 19 if ($allen_xsite) { return 403; } 20 if ($allen_notjson) { return 415; } 21 limit_except POST { deny all; } 22 limit_req zone=allen_chat burst=4 nodelay; 23 limit_conn allen_conn 4; 24 client_max_body_size 72k; 25 proxy_pass http://allen_chat_gateway; 26 proxy_http_version 1.1; 27 proxy_set_header Connection ""; 28 proxy_set_header Host allen-chat; 29 proxy_set_header X-Real-IP $proxy_protocol_addr; 30 proxy_set_header X-Forwarded-For ""; 31 proxy_buffering off; 32 proxy_cache off; 33 proxy_connect_timeout 3s; 34 proxy_send_timeout 30s; 35 proxy_read_timeout 180s; 36 gzip off; 37 } 38 39 location = /allen/api/infer { 40 if ($proxy_protocol_addr = "") { return 503; } 41 if ($allen_xsite) { return 403; } 42 if ($allen_notjson) { return 415; } 43 limit_except POST { deny all; } 44 limit_req zone=allen_infer burst=6 nodelay; 45 limit_conn allen_conn 4; 46 client_max_body_size 72k; 47 proxy_pass http://allen_chat_gateway; 48 proxy_http_version 1.1; 49 proxy_set_header Connection ""; 50 proxy_set_header Host allen-chat; 51 proxy_set_header X-Real-IP $proxy_protocol_addr; 52 proxy_set_header X-Forwarded-For ""; 53 proxy_buffering off; 54 proxy_cache off; 55 proxy_connect_timeout 3s; 56 proxy_send_timeout 30s; 57 proxy_read_timeout 120s; 58 gzip off; 59 } 60 location = /allen/api/infer-verify { 61 if ($proxy_protocol_addr = "") { return 503; } 62 if ($allen_xsite) { return 403; } 63 if ($allen_notjson) { return 415; } 64 limit_except POST { deny all; } 65 limit_req zone=allen_api burst=10 nodelay; 66 client_max_body_size 64k; 67 proxy_pass http://allen_chat_gateway; 68 proxy_http_version 1.1; 69 proxy_set_header Connection ""; 70 proxy_set_header Host allen-chat; 71 proxy_set_header X-Real-IP $proxy_protocol_addr; 72 proxy_set_header X-Forwarded-For ""; 73 proxy_connect_timeout 3s; 74 proxy_read_timeout 10s; 75 } 76 # Math panes on /aien/: one expression to the Omega math engine (allen_math.py). 77 location = /allen/api/math { 78 if ($proxy_protocol_addr = "") { return 503; } 79 if ($allen_xsite) { return 403; } 80 if ($allen_notjson) { return 415; } 81 limit_except POST { deny all; } 82 limit_req zone=allen_omega burst=6 nodelay; 83 limit_conn allen_conn 4; 84 client_max_body_size 16k; 85 proxy_pass http://allen_chat_gateway; 86 proxy_http_version 1.1; 87 proxy_set_header Connection ""; 88 proxy_set_header Host allen-chat; 89 proxy_set_header X-Real-IP $proxy_protocol_addr; 90 proxy_set_header X-Forwarded-For ""; 91 proxy_connect_timeout 3s; 92 proxy_read_timeout 30s; 93 } 94 location = /allen/api/infer-info { 95 if ($proxy_protocol_addr = "") { return 503; } 96 limit_except GET { deny all; } 97 limit_req zone=allen_api burst=20 nodelay; 98 proxy_pass http://allen_chat_gateway; 99 proxy_http_version 1.1; 100 proxy_set_header Connection ""; 101 proxy_set_header Host allen-chat; 102 proxy_set_header X-Real-IP $proxy_protocol_addr; 103 proxy_set_header X-Forwarded-For ""; 104 proxy_connect_timeout 3s; 105 proxy_read_timeout 10s; 106 } 107 location = /allen/api/omega { 108 if ($proxy_protocol_addr = "") { return 503; } 109 if ($allen_xsite) { return 403; } 110 if ($allen_notjson) { return 415; } 111 limit_except POST { deny all; } 112 limit_req zone=allen_omega burst=6 nodelay; 113 limit_conn allen_conn 4; 114 client_max_body_size 24k; 115 proxy_pass http://allen_chat_gateway; 116 proxy_http_version 1.1; 117 proxy_set_header Connection ""; 118 proxy_set_header Host allen-chat; 119 proxy_set_header X-Real-IP $proxy_protocol_addr; 120 proxy_set_header X-Forwarded-For ""; 121 proxy_connect_timeout 3s; 122 proxy_read_timeout 30s; 123 } 124 125 # A2A 1.0 JSON-RPC for the introduce door only. Public POST /aien/api/a2a 126 # rewrites to this exact path. SendMessage (legacy name message/send) is the 127 # one method. Every other method is a JSON-RPC error from the gateway. 128 # Consent and no-store match introduce: nothing is stored unless consent is 129 # the JSON boolean true, and the response carries Cache-Control: no-store. 130 # Agora's board is a different service at /agora/a2a. 131 # application/a2a+json is allowed here via $allen_a2a_notjson. $allen_notjson 132 # would answer 415 for that media type, so this location does not use it. 133 location = /allen/api/a2a { 134 if ($proxy_protocol_addr = "") { return 503; } 135 if ($allen_xsite) { return 403; } 136 if ($allen_a2a_notjson) { return 415; } 137 limit_except POST { deny all; } 138 limit_req zone=allen_submit burst=3 nodelay; 139 limit_conn allen_conn 4; 140 client_max_body_size 72k; 141 proxy_pass http://allen_chat_gateway; 142 proxy_http_version 1.1; 143 proxy_set_header Connection ""; 144 proxy_set_header Host allen-chat; 145 proxy_set_header X-Real-IP $proxy_protocol_addr; 146 proxy_set_header X-Forwarded-For ""; 147 proxy_connect_timeout 3s; 148 proxy_read_timeout 15s; 149 } 150 151 # Visitor-confirmed issue/project proposals, consented introductions, deletions. 152 location ~ ^/allen/api/(submit|introduce|forget|forget-me)$ { 153 if ($proxy_protocol_addr = "") { return 503; } 154 if ($allen_xsite) { return 403; } 155 if ($allen_notjson) { return 415; } 156 limit_except POST { deny all; } 157 limit_req zone=allen_submit burst=3 nodelay; 158 limit_conn allen_conn 4; 159 client_max_body_size 300k; 160 proxy_pass http://allen_chat_gateway; 161 proxy_http_version 1.1; 162 proxy_set_header Connection ""; 163 proxy_set_header Host allen-chat; 164 proxy_set_header X-Real-IP $proxy_protocol_addr; 165 proxy_set_header X-Forwarded-For ""; 166 proxy_connect_timeout 3s; 167 proxy_read_timeout 15s; 168 } 169 170 # Reaching Drake (relay, handoff, say) and a key holder's project summary sync. 171 location ~ ^/allen/api/(relay|handoff|say|project-summary)$ { 172 if ($proxy_protocol_addr = "") { return 503; } 173 if ($allen_xsite) { return 403; } 174 if ($allen_notjson) { return 415; } 175 limit_except POST { deny all; } 176 limit_req zone=allen_submit burst=3 nodelay; 177 limit_conn allen_conn 4; 178 client_max_body_size 72k; 179 proxy_pass http://allen_chat_gateway; 180 proxy_http_version 1.1; 181 proxy_set_header Connection ""; 182 proxy_set_header Host allen-chat; 183 proxy_set_header X-Real-IP $proxy_protocol_addr; 184 proxy_set_header X-Forwarded-For ""; 185 proxy_connect_timeout 3s; 186 proxy_read_timeout 15s; 187 } 188 189 # Project homes in aien-dev/omega-projects: a handle, a save (one commit on u/) or a 190 # publish (a pull request for Drake). Ownership, file allowlist and caps are checked in the gateway. 191 location ~ ^/allen/api/projects/(handle|save|publish)$ { 192 if ($proxy_protocol_addr = "") { return 503; } 193 if ($allen_xsite) { return 403; } 194 if ($allen_notjson) { return 415; } 195 limit_except POST { deny all; } 196 limit_req zone=allen_submit burst=3 nodelay; 197 limit_conn allen_conn 4; 198 client_max_body_size 300k; 199 proxy_pass http://allen_chat_gateway; 200 proxy_http_version 1.1; 201 proxy_set_header Connection ""; 202 proxy_set_header Host allen-chat; 203 proxy_set_header X-Real-IP $proxy_protocol_addr; 204 proxy_set_header X-Forwarded-For ""; 205 proxy_connect_timeout 3s; 206 proxy_read_timeout 15s; 207 } 208 209 # The caller's own handle, and the gallery of merged projects. 210 location ~ ^/allen/api/(projects/me|gallery)$ { 211 if ($proxy_protocol_addr = "") { return 503; } 212 limit_except GET { deny all; } 213 limit_req zone=allen_api burst=20 nodelay; 214 proxy_pass http://allen_chat_gateway; 215 proxy_http_version 1.1; 216 proxy_set_header Connection ""; 217 proxy_set_header Host allen-chat; 218 proxy_set_header X-Real-IP $proxy_protocol_addr; 219 proxy_set_header X-Forwarded-For ""; 220 proxy_connect_timeout 3s; 221 proxy_read_timeout 10s; 222 } 223 224 # Push-to-talk: one short raw audio clip (audio/webm, audio/ogg or audio/wav), transcribed 225 # on the Spark's CPU. Same rate as chat, own zone, so a voice turn does not spend chat budget. 226 location = /allen/api/transcribe { 227 if ($proxy_protocol_addr = "") { return 503; } 228 if ($allen_xsite) { return 403; } 229 limit_except POST { deny all; } 230 limit_req zone=allen_voice burst=4 nodelay; 231 limit_conn allen_conn 4; 232 client_max_body_size 1m; 233 proxy_pass http://allen_chat_gateway; 234 proxy_http_version 1.1; 235 proxy_set_header Connection ""; 236 proxy_set_header Host allen-chat; 237 proxy_set_header X-Real-IP $proxy_protocol_addr; 238 proxy_set_header X-Forwarded-For ""; 239 proxy_connect_timeout 3s; 240 proxy_read_timeout 30s; 241 } 242 243 location = /allen/api/presence { 244 if ($proxy_protocol_addr = "") { return 503; } 245 limit_except GET { deny all; } 246 limit_req zone=allen_api burst=20 nodelay; 247 proxy_pass http://allen_chat_gateway; 248 proxy_http_version 1.1; 249 proxy_set_header Connection ""; 250 proxy_set_header Host allen-chat; 251 proxy_set_header X-Real-IP $proxy_protocol_addr; 252 proxy_set_header X-Forwarded-For ""; 253 proxy_connect_timeout 3s; 254 proxy_read_timeout 10s; 255 } 256 257 # The live session channel (SSE): unbuffered, held up to an hour (heartbeat every 15 s). 258 location = /allen/api/session { 259 if ($proxy_protocol_addr = "") { return 503; } 260 limit_except GET { deny all; } 261 limit_req zone=allen_api burst=10 nodelay; 262 limit_conn allen_conn 4; 263 proxy_pass http://allen_chat_gateway; 264 proxy_http_version 1.1; 265 proxy_set_header Connection ""; 266 proxy_set_header Host allen-chat; 267 proxy_set_header X-Real-IP $proxy_protocol_addr; 268 proxy_set_header X-Forwarded-For ""; 269 proxy_buffering off; 270 proxy_cache off; 271 proxy_connect_timeout 3s; 272 proxy_send_timeout 30s; 273 proxy_read_timeout 1h; 274 gzip off; 275 } 276 277 # Drake's console (100.64.0.2:18112) is never proxied: no route here reaches it. 278 279 location ~ "^/allen/api/status/[0-9a-f]{20}$" { 280 if ($proxy_protocol_addr = "") { return 503; } 281 limit_except GET { deny all; } 282 limit_req zone=allen_api burst=20 nodelay; 283 proxy_pass http://allen_chat_gateway; 284 proxy_http_version 1.1; 285 proxy_set_header Connection ""; 286 proxy_set_header Host allen-chat; 287 proxy_set_header X-Real-IP $proxy_protocol_addr; 288 proxy_set_header X-Forwarded-For ""; 289 proxy_connect_timeout 3s; 290 proxy_read_timeout 10s; 291 } 292 293 return 404; 294 } 295 296 location = /allen/api { 297 access_log off; 298 return 404; 299 } 300 301 # Edge rate-limit refusals answer in the gateway's JSON shape. 302 location @allen_rate { 303 access_log off; 304 default_type application/json; 305 add_header Retry-After 20 always; 306 add_header Cache-Control "no-store" always; 307 add_header X-Content-Type-Options nosniff always; 308 add_header Strict-Transport-Security "max-age=`31536000`; includeSubDomains" always; 309 add_header Content-Security-Policy "default-src 'none'; frame-ancestors 'none'" always; 310 return 429 '{"error":"rate","message":"You are sending requests quickly. Try again shortly.","retry_after":20}'; 311 } 312 313 # /aien/api/ is the current name of the same API. It re-enters the /allen/api/ 314 # routes above by internal rewrite, so every gate, limit and header applies once. 315 location ^~ /aien/api/ { 316 access_log off; 317 rewrite ^/aien/api/(.*)$ /allen/api/$1 last; 318 } 319 320 location = /aien/api { 321 access_log off; 322 return 404; 323 }