Created
April 13, 2018 12:29
-
-
Save caquino/ab3aabe5b0ba966a581ad649d7bbffe0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resolver consul:8600 valid=2s ipv6=off; | |
resolver_timeout 2s; | |
proxy_cache_path /tmp/nginx levels=1:2 keys_zone=default:10m max_size=50m; | |
upstream backends { | |
zone backends 32k; | |
server service.consul service=backend resolve; | |
} | |
server { | |
status_zone default; | |
listen 80; | |
server_name _; | |
root /usr/share/nginx/html; | |
add_header X-Cache-Status $upstream_cache_status; | |
location / { | |
mirror /mirror; | |
mirror_request_body off; | |
proxy_cache_valid 200 1m; | |
proxy_cache default; | |
proxy_cache_key $uri; | |
proxy_pass http://backends; | |
} | |
location /mirror { | |
internal; | |
if ($request_method ~ "HEAD|GET") { | |
return 204; | |
} | |
proxy_pass_request_body off; | |
proxy_set_header Content-Length ""; | |
proxy_cache_purge 1; | |
proxy_cache default; | |
proxy_cache_key $request_uri; | |
proxy_pass http://backends$request_uri; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment