-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathentry-api.sh
More file actions
executable file
·37 lines (30 loc) · 1.29 KB
/
entry-api.sh
File metadata and controls
executable file
·37 lines (30 loc) · 1.29 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
#!/bin/sh -e
# Add IP addresses to geo block for rate limit exclusion
if [ -n "$TRUSTED_IPS" ]; then
# Split IPs by comma and add each one to geo block
for ip in $(echo "$TRUSTED_IPS" | tr ',' ' '); do
# Remove any whitespace
ip=$(echo "$ip" | tr -d ' ')
if [ -n "$ip" ]; then
# Insert the IP before the default line in geo block
sed -i "/default \$binary_remote_addr;/i\\ $ip \"\";" /etc/nginx/nginx.conf
fi
done
fi
# Replace TRUSTED_IPS placeholder in uwsgi_param with actual value
if [ -n "$TRUSTED_IPS" ]; then
sed -i "s|TRUSTED_IPS_PLACEHOLDER|$TRUSTED_IPS|g" /etc/nginx/nginx.conf
else
sed -i "s|TRUSTED_IPS_PLACEHOLDER||g" /etc/nginx/nginx.conf
fi
# Disable rate limiting if ENABLE_RATE_LIMIT is not set to true
if [ "$ENABLE_RATE_LIMIT" != "true" ]; then
# Comment out limit_req_zone directive
sed -i 's/limit_req_zone/#limit_req_zone/' /etc/nginx/nginx.conf
# Comment out limit_req directive in server block
sed -i 's/limit_req zone/#limit_req zone/' /etc/nginx/nginx.conf
# Comment out limit_req_status and limit_req_log_level
sed -i 's/limit_req_status/#limit_req_status/' /etc/nginx/nginx.conf
sed -i 's/limit_req_log_level/#limit_req_log_level/' /etc/nginx/nginx.conf
fi
nginx -g "daemon off;"