H
H
HoHsi2016-04-05 09:45:24
Nginx
HoHsi, 2016-04-05 09:45:24

How to make Basic authorization on a remote host in Nginx?

Good afternoon!
At the moment, I have Basic Auth authorization in my private Docker registry. The task was to proxy requests through Nginx to it.
Docker Registry and Nginx are on different machines, i.e. nginx forwards a proxy to a remote machine. Because of this, I cannot do auth authorization on the nginx side.
How can I make it so that nginx sends authorization to a remote host, so that the register itself authorizes the user?
Now push to register responds:

Error parsing HTTP response: invalid character '<' looking for beginning of value: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>403 Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\n<p>You don't have permission to access /v2/busybox/blobs/uploads/<uuid>\non this server.<br />\n</p>\n<hr>\n<address>Apache/2.4.10 (Debian) Server at docker.example.com Port 80</address>\n</body></html>\n"

<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<h1>Forbidden</h1>
<p>You don't have permission to access /v2/busybox/blobs/uploads/<uuid>
on this server.<br />
</p>
<hr>
<address>Apache/2.4.10 (Debian) Server at docker.example.com Port 80</address>
</body>
</html>

upstream docker_example_com_registry {
    server <remote_registry_ip>:5000;
}

###
# Registry
###
server {
    listen          5000 ssl http2;
    server_name     docker.example.com;

    # SSL
    include         /etc/nginx/snippets/ssl.conf;
    include         /etc/nginx/snippets/ssl_example.com.conf;

    client_max_body_size 1024M;

    chunked_transfer_encoding on;

    location / {
        # Trust Proxy
        include /etc/nginx/snippets/trust_proxy.conf;

        proxy_pass http://docker_example_com_registry;
   }
}

At the same time, pushing to the local host works

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton B, 2016-04-05
@bigton

Perhaps proxy_set_header
will help you Also see Basic access authentication

A
avost, 2016-04-12
@avost

The solution to your problem lies in the scope of the auth_request directive.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question