mirror of
https://github.com/docker/docs.git
synced 2026-04-02 17:28:55 +07:00
Merge pull request #351 from forkbomber/distribution-registry-nginx-reverse-proxy-avoid-second-api-version-header
Registry: do not append second Docker-Distribution-Api-Version on Nginx reverse proxy
This commit is contained in:
@@ -83,7 +83,7 @@ Create the main nginx configuration you will use.
|
||||
|
||||
```
|
||||
|
||||
cat <<EOF > auth/nginx.conf
|
||||
cat > auth/nginx.conf << 'EOF'
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
@@ -99,9 +99,8 @@ http {
|
||||
## The registry always sets this header.
|
||||
## In the case of nginx performing auth, the header will be unset
|
||||
## since nginx is auth-ing before proxying.
|
||||
map \$upstream_http_docker_distribution_api_version \$docker_distribution_api_version {
|
||||
'registry/2.0' '';
|
||||
default registry/2.0;
|
||||
map $upstream_http_docker_distribution_api_version $docker_distribution_api_version {
|
||||
'' 'registry/2.0';
|
||||
}
|
||||
|
||||
server {
|
||||
@@ -127,7 +126,7 @@ http {
|
||||
location /v2/ {
|
||||
# Do not allow connections from docker 1.5 and earlier
|
||||
# docker pre-1.6.0 did not properly set the user agent on ping, catch "Go *" user agents
|
||||
if (\$http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*\$" ) {
|
||||
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
@@ -137,13 +136,13 @@ http {
|
||||
|
||||
## If $docker_distribution_api_version is empty, the header will not be added.
|
||||
## See the map directive above where this variable is defined.
|
||||
add_header 'Docker-Distribution-Api-Version' \$docker_distribution_api_version always;
|
||||
add_header 'Docker-Distribution-Api-Version' $docker_distribution_api_version always;
|
||||
|
||||
proxy_pass http://docker-registry;
|
||||
proxy_set_header Host \$http_host; # required for docker client's sake
|
||||
proxy_set_header X-Real-IP \$remote_addr; # pass on real client's IP
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||
proxy_set_header Host $http_host; # required for docker client's sake
|
||||
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 900;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user