| | 69 | |
| | 70 | conf. |
| | 71 | |
| | 72 | {{{ |
| | 73 | worker_processes 1; |
| | 74 | |
| | 75 | events { |
| | 76 | worker_connections 1024; |
| | 77 | } |
| | 78 | |
| | 79 | |
| | 80 | http { |
| | 81 | include mime.types; |
| | 82 | default_type application/octet-stream; |
| | 83 | |
| | 84 | sendfile on; |
| | 85 | keepalive_timeout 65; |
| | 86 | |
| | 87 | upstream upstream_http { |
| | 88 | server unix:/run/nginx_1.sock max_fails=1 fail_timeout=10s; |
| | 89 | server unix:/run/nginx_2.sock max_fails=1 fail_timeout=10s backup; |
| | 90 | } |
| | 91 | |
| | 92 | server { |
| | 93 | listen unix:/run/nginx_1.sock; |
| | 94 | |
| | 95 | access_log /var/log/nginx/access_y.log; |
| | 96 | error_log /var/log/nginx/error_1.log debug; |
| | 97 | |
| | 98 | location / { |
| | 99 | resolver 127.0.0.53; |
| | 100 | resolver_timeout 5s; |
| | 101 | proxy_http_version 1.1; |
| | 102 | proxy_pass ht tp://fail.example.com/$request_uri; |
| | 103 | proxy_set_header Connection ""; |
| | 104 | proxy_set_header Host "fail.example.com"; |
| | 105 | proxy_pass_header x-accel-expires; |
| | 106 | } |
| | 107 | } |
| | 108 | |
| | 109 | server { |
| | 110 | listen unix:/run/nginx_2.sock; |
| | 111 | |
| | 112 | access_log /var/log/nginx/access_y.log; |
| | 113 | error_log /var/log/nginx/error_2.log debug; |
| | 114 | |
| | 115 | location / { |
| | 116 | resolver 127.0.0.53; |
| | 117 | resolver_timeout 5s; |
| | 118 | proxy_http_version 1.1; |
| | 119 | proxy_pass ht tp://success.example.com/$request_uri; |
| | 120 | proxy_set_header Connection ""; |
| | 121 | proxy_pass_header x-accel-expires; |
| | 122 | } |
| | 123 | } |
| | 124 | proxy_cache_path /var/data/cache/ levels=1:2 use_temp_path=off keys_zone=cache_all:365516 inactive=720m max_size=539553; |
| | 125 | |
| | 126 | server { |
| | 127 | listen 80; |
| | 128 | server_name localhost; |
| | 129 | access_log /var/log/nginx/access_y.log; |
| | 130 | error_log /var/log/nginx/error_x.log debug; |
| | 131 | |
| | 132 | proxy_cache_lock on; |
| | 133 | proxy_cache_lock_timeout 10s; |
| | 134 | proxy_cache_revalidate on; |
| | 135 | proxy_cache_min_uses 1; |
| | 136 | proxy_set_header Connection ""; |
| | 137 | proxy_http_version 1.1; |
| | 138 | proxy_next_upstream http_500 http_502 http_503 http_504 http_429 timeout; |
| | 139 | |
| | 140 | location / { |
| | 141 | proxy_cache cache_all; |
| | 142 | proxy_pass ht tp://upstream_http; |
| | 143 | add_header X-Cache-Status $upstream_cache_status; |
| | 144 | } |
| | 145 | } |
| | 146 | } |
| | 147 | }}} |