Перейти к содержанию

Модуль 2. Задание 9-10.

Решение

ISP

Необходимые пакеты:

apt-get install nginx apache2-htpasswd

Отключаем базовые службы:

systemctl disable --now ahttpd httpd2

На всякий случай:

fuser -k 80/tcp

Включаем службу:

systemctl enable --now nginx

Конфигурируем /etc/nginx/sites-enabled.d/proxy.conf:

server {
    lister 80;
    server_name web.au-team.irpo;

    location / {
        auth_basic "web";
        auth_basic_user_file /etc/nginx/.htpasswd;

        proxy_pass http://172.16.1.2:8080;
    }
}

server {
    listen 80;
    server_name docker.au-team.irpo;

    location / {
        auth_basic "docker";
        auth_basic_user_file /etc/nginx/.htpasswd;

        proxy_pass http://172.16.2.2:8080;
    }
}

Создаём .htpasswd:

htpasswd -c -b /etc/nginx/.htpasswd WEB P@ssw0rd

Перезапускаем nginx:

nginx -s reload