-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.conf
89 lines (72 loc) · 3.38 KB
/
nginx.conf
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
81
82
83
84
85
86
87
88
89
http {
# limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
# limit_req_zone $http_x_forwarded_for zone=req_limit_per_ip:10m rate=10r/s;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=thumbnail_cache:500m max_size=5g inactive=2h use_temp_path=off;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# todo fix this mad body size limit so its just under proxy location
client_max_body_size 11M;
server {
# limit_conn conn_limit_per_ip 10;
# proxy_connect_timeout10s;
# proxy_send_timeout 10s;
# proxy_read_timeout 10s;
# limit_req zone=req_limit_per_ip burst=5 nodelay;
listen 80;
# server_name example.org; # DO KOREKTY
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
charset utf-8;
# Health check location
location /healthcheck {
access_log off; # Optional: Disable logging for health check requests
return 200 'Nginx is healthy'; # Always return 200 OK for health check
add_header Content-Type text/plain; # Set content type
}
location ~ ^/api/file/thumbnail/(.*) {
# Enable caching
proxy_cache thumbnail_cache;
proxy_cache_valid 200 30d; # Cache for 30 days on 200 OK responses
proxy_cache_valid 404 1m; # Cache for 1 minute for 404 responses (optional)
proxy_cache_use_stale error timeout updating; # Use stale cache if the backend is down
# Cache headers (optional)
add_header X-Cache-Status $upstream_cache_status;
# Proxy settings to pass the request to the backend server
# Remove /api from the URL
rewrite ^/api/file/thumbnail/(.*) /file/thumbnail/$1 break;
# Proxy pass to backend without the /api part
proxy_pass http://backend:8000;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /proxy/discord/ {
client_max_body_size 11M;
proxy_pass http://backend:8000/; # passes unchanged path to backend
proxy_set_header Host $host; # sets http host header to the name of the original caller - so it changes nothing
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Protocol $scheme;
}
location /api/ {
proxy_pass http://backend:8000/; # passes unchanged path to backend
proxy_set_header Host $host; # sets http host header to the name of the original caller - so it changes nothing
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Protocol $scheme;
}
location / {
root /var/www/idrive/frontend;
try_files $uri /index.html;
include /etc/nginx/mime.types;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
#a tu to co ma byc?
events {}