-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
110 lines (89 loc) · 3.42 KB
/
nginx.conf
File metadata and controls
110 lines (89 loc) · 3.42 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
worker_processes auto;
worker_rlimit_nofile 65535;
error_log stderr warn;
pid /tmp/nginx.pid;
events {
multi_accept on;
worker_connections 1024;
}
http {
client_body_temp_path /tmp/client_temp;
proxy_temp_path /tmp/proxy_temp_path;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"';
access_log /dev/stdout main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 10M;
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s;
limit_req_zone $binary_remote_addr zone=static:10m rate=100r/s;
limit_req_status 429;
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_conn_status 429;
client_body_buffer_size 128k;
client_header_buffer_size 1k;
large_client_header_buffers 4 8k;
client_body_timeout 12;
client_header_timeout 12;
send_timeout 10;
server_tokens off;
map $http_user_agent $bad_bot {
default 0;
~*(bot|crawler|spider|scanner|wget|curl|python|java|perl|ruby|php|nikto|sqlmap) 1;
~*(Ahrefs|Semrush|MJ12bot|BLEXBot|DotBot|Baidu|Yandex) 1;
}
server {
listen 8080;
server_name _;
if ($bad_bot) {
return 403;
}
location ~* /\. {
return 404;
}
location ~* ^/(__debug__|debug|env|secrets|\.env|\.git|\.svn|\.hg|\.idea|\.vscode) {
return 404;
}
location /login {
limit_req zone=login burst=5 delay=3;
proxy_pass http://127.0.0.1:8000/login;
include /etc/nginx/proxy_params;
}
location /api {
limit_req zone=api burst=50 nodelay;
proxy_pass http://127.0.0.1:8000/api;
include /etc/nginx/proxy_params;
}
location /health {
access_log off;
proxy_pass http://127.0.0.1:8000/health;
include /etc/nginx/proxy_params;
}
location / {
limit_except GET POST {
deny all;
}
limit_conn conn_limit_per_ip 10;
proxy_pass http://127.0.0.1:8000;
include /etc/nginx/proxy_params;
}
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' https://img.icons8.com https://www.debian.org data:; font-src 'self'; connect-src 'self';" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
}
}