82 lines
2.7 KiB
Plaintext
82 lines
2.7 KiB
Plaintext
# FLNXI premium module Registry pull proxy.
|
|
# The Docker image push path should stay on the publisher-only Registry entry.
|
|
# Customer pulls for /v2/flnxi/premium/* are checked by license-server /api/registry/auth.
|
|
|
|
map $request_method $flnxi_is_pull_method {
|
|
default 0;
|
|
GET 1;
|
|
HEAD 1;
|
|
}
|
|
|
|
map $module_reference $module_digest_header {
|
|
default "";
|
|
~^sha256: $module_reference;
|
|
}
|
|
|
|
server {
|
|
listen 5000;
|
|
server_name _;
|
|
client_max_body_size 0;
|
|
|
|
proxy_read_timeout 900;
|
|
proxy_send_timeout 900;
|
|
proxy_request_buffering off;
|
|
|
|
error_page 401 = @flnxi_module_auth_required;
|
|
|
|
location = /v2/ {
|
|
if ($http_authorization = "") {
|
|
add_header Docker-Distribution-Api-Version registry/2.0 always;
|
|
add_header WWW-Authenticate 'Basic realm="flnxi premium modules"' always;
|
|
return 401;
|
|
}
|
|
|
|
add_header Docker-Distribution-Api-Version registry/2.0 always;
|
|
add_header Content-Type application/json;
|
|
return 200 '{}';
|
|
}
|
|
|
|
location ~ ^/v2/(?<module_repository>flnxi/premium/[^/]+)/(?<module_reference_type>manifests|blobs)/(?<module_reference>.+)$ {
|
|
if ($flnxi_is_pull_method = 0) {
|
|
return 403;
|
|
}
|
|
|
|
auth_request /_flnxi_module_auth;
|
|
auth_request_set $flnxi_auth_status $upstream_status;
|
|
|
|
proxy_pass ${REGISTRY_BACKEND};
|
|
proxy_set_header Authorization "${REGISTRY_BACKEND_AUTH}";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location = /_flnxi_module_auth {
|
|
internal;
|
|
proxy_pass ${LICENSE_SERVER_AUTH_URL};
|
|
proxy_pass_request_body off;
|
|
proxy_set_header Content-Length "";
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_set_header X-Registry-Host $http_host;
|
|
proxy_set_header X-Registry-Repository $module_repository;
|
|
proxy_set_header X-Registry-Reference-Type $module_reference_type;
|
|
proxy_set_header X-Registry-Reference $module_reference;
|
|
proxy_set_header X-Registry-Digest $module_digest_header;
|
|
proxy_set_header X-Registry-Scope "repository:$module_repository:pull";
|
|
proxy_set_header X-Original-URI $request_uri;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
|
|
location /v2/ {
|
|
return 403;
|
|
}
|
|
|
|
location @flnxi_module_auth_required {
|
|
add_header Docker-Distribution-Api-Version registry/2.0 always;
|
|
add_header WWW-Authenticate 'Basic realm="flnxi premium modules"' always;
|
|
return 401;
|
|
}
|
|
}
|