B
B
brezhitskiy422020-10-13 13:18:09
Nginx
brezhitskiy42, 2020-10-13 13:18:09

How to enable Nginx to read docker.sock?

There is a server with docker and nginx. We need the ability to connect via websocket with containers ( doc .). nginx config:

server {
    server_name domain.ru;

    location ~ws/?$ {
        proxy_pass http://unix:/var/run/docker.sock;
        proxy_http_version 1.1;
        proxy_set_header Upgrade "websocket";
        proxy_set_header Connection "upgrade";
    }
}


When trying to connect, the websocket gives a 502 error, and in nginx.error:
connect() to unix:/var/run/docker.sock failed (13: Permission denied


As I understand it, the problem is that nginx runs under www-data, and docker.sock runs under the docker group. You can do sudo usermod -aGdocker www-datait, but I understand that it is not safe.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Vasilyev, 2020-10-13
@vasilyevmn

Answer here:
https://docs.docker.com/engine/install/linux-posti...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question