basic auth для веб-интерфейса

Skip to end of metadata
Go to start of metadata
Вы просматриваете старую версию данной страницы. Смотрите текущую версию. Сравнить с текущим  |   просмотр истории страницы

1. Это временное решение, когда будет совершён переход на Carbon PL5 Linux всё будет работать немного иначе.
2. Список администраторов из веб-интерфейса нужно будет добавлять в конфиг руками.

htpasswd -bc '/usr/local/Reductor/userinfo/hooks/nginx_htpasswd' 'admin' 'yourpassword'

Берём конфиг и кладём его /usr/local/Reductor/userinfo/hooks/nginx_reductor.conf:

# Configuration for Nginx
server {
        listen 10.50.140.230:8080;

# Serve a static file (ex. favico) outside static dir.
        location = /favico.ico  {
                root /app/favico.ico;
        }

# Proxying connections to application servers
        allow 10.50.140.222;
        deny all;
        location / {
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $host;
                proxy_pass http://127.0.0.1:8085;
        }
}

Добавляем htpasswd:

# Configuration for Nginx
server {
        listen 10.50.140.230:8080;

# Serve a static file (ex. favico) outside static dir.
        location = /favico.ico  {
                root /app/favico.ico;
        }

# Proxying connections to application servers
        allow 10.50.140.222;
        deny all;
        location / {
                auth_basic "Not Found 404"; # текст сообщения сервера с предложением ввести пароль
                auth_basic_user_file /usr/local/Reductor/userinfo/hooks/nginx_htpasswd; # путь к htpasswd файлу

                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $host;
                proxy_pass http://127.0.0.1:8085;
        }
}

Создаём хук /usr/local/Reductor/userinfo/hooks/start.sh

#!/bin/bash

client_post_start_hook() {
        echo "- Включаем basic auth в nginx"
        cp -a $HOOKDIR/nginx_reductor.conf /etc/nginx/conf.d/
        service nginx reload || service nginx restart || true
}

делаем его исполняемым:

chmod a+x /usr/local/Reductor/userinfo/hooks/start.sh

Применяем всё что мы сделали:

service reductor restart
Введите метки, чтобы добавить к этой странице:
Please wait 
Ищите метку? просто начните печатать.