optiopay / klar

Integration of Clair and Docker Registry
MIT License
506 stars 140 forks source link

Strip port from Clair URL if we use https and define port 443 #146

Closed mindjiver closed 2 years ago

mindjiver commented 5 years ago

To avoid confusing upstream proxy servers if the port is defined as well as the protocol we remove the port if it is 443 and we have defined the protocol to be https.

The reason for this change is that when running Clair behind Envoy the vhost lookup failed when the port as also included in the host header.

The call to Clair with klar and the same call using curl can be seen here below, the additional port caused the vhost lookup to fail. Not defining the port at all would mean that we get the default port, 6060, for which Envoy is not listening.

ACCESS [2019-03-19T10:32:10.770Z] "POST /v1/layers HTTP/1.1" 404 NR 0 0 0 - "-" "Go-http-client/1.1" "768ea0ea-092c-44a8-93a7-50ef87cb3a19" "clair:443" "-"
ACCESS [2019-03-19T10:34:34.511Z] "POST /v1/layers HTTP/1.1" 201 - 2950 2940 214 4 "-" "curl/7.54.0" "61828ee9-5a1c-4842-9da1-fd360a4c3b4b" "clair" "100.68.74.2:6060"