-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnginx.conf.template
More file actions
80 lines (68 loc) · 3.33 KB
/
nginx.conf.template
File metadata and controls
80 lines (68 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/xml+rss
application/json;
server {
listen 8080;
server_name _;
root /usr/share/nginx/html;
index index.html;
# File upload limits
client_max_body_size 50M;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://clerk.typelets.com https://*.clerk.accounts.dev https://static.cloudflareinsights.com https://cdn.jsdelivr.net blob:; script-src-elem 'self' 'unsafe-inline' https://clerk.typelets.com https://*.clerk.accounts.dev https://static.cloudflareinsights.com https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline' https://clerk.typelets.com https://fonts.googleapis.com https://cdn.jsdelivr.net; style-src-elem 'self' 'unsafe-inline' https://fonts.googleapis.com https://clerk.typelets.com https://cdn.jsdelivr.net; img-src 'self' data: https: blob:; font-src 'self' data: https://clerk.typelets.com https://fonts.gstatic.com https://cdn.jsdelivr.net; connect-src 'self' https://clerk.typelets.com https://*.clerk.accounts.dev https://cloudflareinsights.com wss://ws-api.typelets.com https://api.typelets.com blob:; frame-src 'self' https://clerk.typelets.com https://*.clerk.accounts.dev https://challenges.cloudflare.com; worker-src 'self' blob:; child-src 'self' blob:;" always;
# === Proxy API requests to backend service ===
location /api/ {
proxy_pass ${BACKEND_URL}/api/;
proxy_http_version 1.1;
proxy_set_header Host ${BACKEND_HOST};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# SSL/TLS settings for HTTPS upstream
proxy_ssl_server_name on;
proxy_ssl_name ${BACKEND_HOST};
# WebSocket support
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# === Client-side routing (SPA fallback) ===
location / {
try_files $uri $uri/ /index.html;
}
# === Cache static assets ===
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# === Health check endpoint ===
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
}