This is my nginx
configuration (running as docker container, in case it matters):
events {
worker_connections 4096; ## Default: 1024
}
http {
server {
server_name registry.mydomain;
listen 80;
listen 443 ssl;
client_max_body_size 0; # Disables checking, to avoid "request entity too large"
ssl_certificate /etc/nginx/certs/registry.crt;
ssl_certificate_key /etc/nginx/certs/registry.key;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://registry:5000;
}
}
}
The problem that I have is that nginx
is serving that site even for requests to other domains. This is expected:
$ http http://registry.mydomain/v2/_catalog?n=100
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 20
Content-Type: application/json; charset=utf-8
Date: Thu, 05 Apr 2018 12:43:21 GMT
Docker-Distribution-Api-Version: registry/2.0
Server: nginx/1.13.11
X-Content-Type-Options: nosniff
{
"repositories": []
}
But this is not expected:
$ http http://localhost/v2/_catalog?n=100
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 20
Content-Type: application/json; charset=utf-8
Date: Thu, 05 Apr 2018 12:39:57 GMT
Docker-Distribution-Api-Version: registry/2.0
Server: nginx/1.13.11
X-Content-Type-Options: nosniff
{
"repositories": []
}
Why is that? How can I tell nginx
to not serve requests to undefined servers?