forked from haicker-app/demo-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
46 lines (38 loc) · 1.57 KB
/
Copy pathnginx.conf
File metadata and controls
46 lines (38 loc) · 1.57 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
events {
worker_connections 1024;
}
http {
# Define cache path and settings
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=static_cache:10m max_size=100m inactive=60m use_temp_path=off;
upstream app_backend {
server app:3000;
}
server {
listen 3000;
location /static {
# Enable server-side caching
proxy_cache static_cache;
proxy_cache_valid 200 301 302 404 500 502 503 504 1m;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_lock on;
proxy_cache_key "$scheme$request_method$host$request_uri";
# Force caching by ignoring cache headers from backend
proxy_ignore_headers Cache-Control Expires Set-Cookie;
proxy_cache_bypass $http_cache_control $http_pragma;
# Add cache status header for debugging
add_header X-Cache-Status $upstream_cache_status;
proxy_pass http://app_backend;
proxy_set_header Host $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;
}
location / {
proxy_pass http://app_backend;
proxy_set_header Host $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;
}
}
}