Upload deploy/nginx.conf.example with huggingface_hub
Browse files- deploy/nginx.conf.example +110 -0
deploy/nginx.conf.example
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sentinel-AI reverse proxy example (nginx)
|
| 2 |
+
#
|
| 3 |
+
# Terminates TLS, forwards to uvicorn on 127.0.0.1:8000, adds a second layer of
|
| 4 |
+
# rate limiting, and enforces an upload cap. Replace the certificate paths and
|
| 5 |
+
# domain before use.
|
| 6 |
+
#
|
| 7 |
+
# Backend:
|
| 8 |
+
# cd backend
|
| 9 |
+
# python -m uvicorn main:app --host 127.0.0.1 --port 8000
|
| 10 |
+
#
|
| 11 |
+
# Then set in .env:
|
| 12 |
+
# SENTINEL_API_KEY=<demo access token>
|
| 13 |
+
# CORS_ORIGINS=https://sentinel.example.com
|
| 14 |
+
# TRUST_PROXY_HEADERS=1
|
| 15 |
+
|
| 16 |
+
limit_req_zone $binary_remote_addr zone=sentinel_api:10m rate=10r/s;
|
| 17 |
+
|
| 18 |
+
upstream sentinel_backend {
|
| 19 |
+
server 127.0.0.1:8000;
|
| 20 |
+
keepalive 32;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
# Redirect HTTP to HTTPS.
|
| 24 |
+
server {
|
| 25 |
+
listen 80;
|
| 26 |
+
listen [::]:80;
|
| 27 |
+
server_name sentinel.example.com;
|
| 28 |
+
|
| 29 |
+
location /.well-known/acme-challenge/ {
|
| 30 |
+
root /var/www/certbot;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
location / {
|
| 34 |
+
return 301 https://$host$request_uri;
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
server {
|
| 39 |
+
listen 443 ssl;
|
| 40 |
+
listen [::]:443 ssl;
|
| 41 |
+
http2 on;
|
| 42 |
+
server_name sentinel.example.com;
|
| 43 |
+
|
| 44 |
+
ssl_certificate /etc/letsencrypt/live/sentinel.example.com/fullchain.pem;
|
| 45 |
+
ssl_certificate_key /etc/letsencrypt/live/sentinel.example.com/privkey.pem;
|
| 46 |
+
ssl_protocols TLSv1.2 TLSv1.3;
|
| 47 |
+
ssl_prefer_server_ciphers off;
|
| 48 |
+
ssl_session_cache shared:SSL:10m;
|
| 49 |
+
ssl_session_timeout 1d;
|
| 50 |
+
|
| 51 |
+
# Upload cap must be a little larger than MAX_UPLOAD_BYTES (10 MiB default).
|
| 52 |
+
client_max_body_size 12m;
|
| 53 |
+
client_body_timeout 30s;
|
| 54 |
+
|
| 55 |
+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
| 56 |
+
add_header X-Content-Type-Options "nosniff" always;
|
| 57 |
+
add_header X-Frame-Options "DENY" always;
|
| 58 |
+
add_header Referrer-Policy "no-referrer" always;
|
| 59 |
+
|
| 60 |
+
# Optional: serve the built dashboard from the same origin. TanStack Start
|
| 61 |
+
# may require its own server if you use SSR; a static build works with this
|
| 62 |
+
# block.
|
| 63 |
+
# root /var/www/sentinel/frontend/dist;
|
| 64 |
+
# index index.html;
|
| 65 |
+
# location / {
|
| 66 |
+
# try_files $uri $uri/ /index.html;
|
| 67 |
+
# }
|
| 68 |
+
|
| 69 |
+
location /api/ {
|
| 70 |
+
limit_req zone=sentinel_api burst=20 nodelay;
|
| 71 |
+
|
| 72 |
+
proxy_pass http://sentinel_backend;
|
| 73 |
+
proxy_http_version 1.1;
|
| 74 |
+
proxy_set_header Host $host;
|
| 75 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 76 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 77 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 78 |
+
proxy_set_header Connection "";
|
| 79 |
+
proxy_connect_timeout 5s;
|
| 80 |
+
proxy_send_timeout 90s;
|
| 81 |
+
proxy_read_timeout 90s;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
location = /health {
|
| 85 |
+
proxy_pass http://sentinel_backend;
|
| 86 |
+
proxy_http_version 1.1;
|
| 87 |
+
proxy_set_header Host $host;
|
| 88 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 89 |
+
access_log off;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
location /docs {
|
| 93 |
+
# Optional: protect the API docs behind the same token or an IP allow-list.
|
| 94 |
+
# allow 10.0.0.0/8;
|
| 95 |
+
# deny all;
|
| 96 |
+
proxy_pass http://sentinel_backend;
|
| 97 |
+
proxy_http_version 1.1;
|
| 98 |
+
proxy_set_header Host $host;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
location /redoc {
|
| 102 |
+
proxy_pass http://sentinel_backend;
|
| 103 |
+
proxy_http_version 1.1;
|
| 104 |
+
proxy_set_header Host $host;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
location / {
|
| 108 |
+
return 404;
|
| 109 |
+
}
|
| 110 |
+
}
|