Вы просматриваете старую версию данной страницы. Смотрите текущую версию.
Сравнить с текущим |
просмотр истории страницы
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