From 87a4e1f417d157482abd8ad8f5150dee1c0d8863 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Tue, 24 Nov 2015 17:02:09 -0500 Subject: [PATCH] 404 on v2 routes for the hostname v1.quay.io This also copies v2 into its own separate location directive because you cannot have nested location directives. Also, the `if` directive can be very tricky and should only be used to return response codes. --- conf/server-base.conf | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/conf/server-base.conf b/conf/server-base.conf index 4a919ba5a..38906ac91 100644 --- a/conf/server-base.conf +++ b/conf/server-base.conf @@ -49,7 +49,30 @@ location ~ ^/(v1/repositories|v2/auth)/ { limit_req zone=repositories burst=10; } -location ~ ^/(v1|v2)/ { +location ~ ^/v2 { + # If we're being accessed via v1.quay.io, pretend we don't support v2. + if ($host = "v1.quay.io") { + return 404; + } + + # Setting ANY header clears all inherited proxy_set_header directives + proxy_set_header X-Forwarded-For $proper_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $host; + + proxy_buffering off; + + proxy_request_buffering off; + + proxy_http_version 1.1; + + proxy_pass http://registry_app_server; + proxy_temp_path /tmp 1 2; + + client_max_body_size 20G; +} + +location ~ ^/v1 { # Setting ANY header clears all inherited proxy_set_header directives proxy_set_header X-Forwarded-For $proper_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;