-
Notifications
You must be signed in to change notification settings - Fork 20
/
nginx.conf
86 lines (67 loc) · 2.32 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
pid logs/nginx.pid;
error_log logs/nginx-main_error.log debug;
# Development Mode
master_process off;
daemon off;
worker_processes 1;
worker_rlimit_core 500M;
working_directory /tmp;
debug_points abort;
events {
worker_connections 1024;
#use kqueue; # MacOS
use epoll; # Linux
}
http {
default_type application/octet-stream;
log_format main '["$time_local"] $remote_addr ($status) $body_bytes_sent $request_time $host '
'$upstream_cache_status $upstream_response_time '
'$http_x_forwarded_for ["$request"] ["$http_user_agent"] ["$http_referer"] ';
access_log logs/nginx-http_access.log main;
error_log logs/nginx-http_error.log;
proxy_cache_path /tmp/cache_zone levels=1:2 keys_zone=zone:10m inactive=1m max_size=100m;
proxy_cache_path /tmp/cache_other_zone levels=1:2 keys_zone=other_zone:1m inactive=10m max_size=10m;
#selective_cache_purge_redis_unix_socket "/tmp/redis.sock";
selective_cache_purge_redis_host localhost;
selective_cache_purge_redis_port 6379;
selective_cache_purge_redis_database 4;
server {
listen 8080;
server_name localhost;
location ~ /purge(.*) {
selective_cache_purge_query "$1*";
}
location / {
add_header "x-cache-status" $upstream_cache_status;
proxy_pass http://localhost:8081;
proxy_cache zone;
proxy_cache_key "$uri";
proxy_cache_valid 200 2m;
proxy_cache_use_stale error timeout invalid_header updating http_500;
}
}
server {
listen 8090;
server_name localhost;
location ~ /purge/.*\.(.*)$ {
selective_cache_purge_query "*$1";
}
location / {
add_header "x-cache-status" $upstream_cache_status;
proxy_pass http://localhost:8081;
proxy_cache other_zone;
proxy_cache_key "$uri";
proxy_cache_valid 200 2m;
}
}
server {
listen 8081;
server_name localhost;
location / {
if ($arg_x = 1) {
return 500 "requested url: $uri\n";
}
return 200 "requested url: $uri\n";
}
}
}