Ticket #2153: nginx.conf

File nginx.conf, 3.0 KB (added by koshikov@…, 6 years ago)

config to repro

Line 
1worker_processes 2;
2error_log /var/log/nginx/error.log;
3pid /var/run/nginx.pid;
4
5daemon off;
6
7events {
8 worker_connections 1024;
9 debug_connection ::1/128;
10}
11
12http {
13 default_type application/octet-stream;
14 keepalive_timeout 65;
15 log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" "$upstream_addr" "$upstream_connect_time" "$upstream_response_time" "$upstream_status"';
16 access_log /var/log/nginx/access.log main;
17 sendfile on;
18 proxy_cache_use_stale timeout updating http_500 http_503 http_504;
19 proxy_cache_background_update on;
20 proxy_connect_timeout 10s;
21 proxy_intercept_errors on;
22 proxy_cache_bypass $http_x_refresh;
23 proxy_cache_path /tmp/package_cache/md use_temp_path=off keys_zone=mdcache:10m inactive=1d max_size=10g;
24 error_page 404 /404.html;
25 error_page 500 502 503 504 /50x.html;
26 proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
27 map $upstream_http_content_length $nocache {
28 "default" 1;
29 "~^0$" 0;
30 }
31 root /home/user/nginx/;
32
33 upstream backend_main {
34 hash 'balance';
35 server [::1]:81 fail_timeout=10;
36 }
37 upstream backend_fallback {
38 hash 'balance';
39 server [::1]:82 fail_timeout=60;
40 }
41 recursive_error_pages on;
42 server {
43 listen [::]:88;
44 server_name _;
45 add_header X-Test 'qwe-88';
46 location / {
47 proxy_pass http://backend_main;
48 proxy_cache mdcache;
49 proxy_cache_valid 1m;
50 add_header X-Header-Root '88-/';
51 add_header Cache-Control "max-age=88" always;
52 error_page 500 502 503 504 = @fallback;
53 }
54 location /url {
55 proxy_pass http://backend_main;
56 proxy_cache mdcache;
57 proxy_cache_valid 1m;
58 add_header X-Header-Root '88-/url';
59 add_header Cache-Control "max-age=888" always;
60 error_page 500 502 503 504 = @fallback;
61 }
62 location @fallback {
63 proxy_pass http://[::]:89;
64 add_header X-Header-Fall '/fallback';
65 }
66 }
67 server {
68 listen [::]:89;
69 server_name _;
70 add_header X-Test 'qwe-89';
71 location / {
72 proxy_pass http://backend_fallback;
73 proxy_cache mdcache;
74 proxy_cache_valid 1m;
75 add_header X-Header-Root '89-/';
76 add_header Cache-Control "max-age=89" always;
77 }
78 location /url {
79 proxy_pass http://backend_fallback;
80 proxy_cache mdcache;
81 proxy_cache_valid 1m;
82 add_header X-Header-Root '89-/url';
83 add_header Cache-Control "max-age=899" always;
84 }
85 }
86 server {
87 listen [::]:81;
88 server_name _;
89 add_header X-Backend '81';
90 location / {
91 if (-f $document_root/81){
92 return 502 "Bad 81";
93 }
94 return 200 'Good 81';
95 add_header Cache-Control "max-age=81" always;
96 }
97 }
98 server {
99 listen [::]:82;
100 server_name _;
101 add_header X-Backend '82';
102 location / {
103 if (-f $document_root/82){
104 return 502 "Bad 82";
105 }
106 return 200 'Good 82';
107 add_header Cache-Control "max-age=82" always;
108 }
109 }
110}