From efe277db2a7d909f674858e6f566e7b3db645edc Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Thu, 23 Sep 2021 23:29:40 +0200 Subject: [PATCH] add basic auth --- roles/nginx/files/kipasswd | 1 + roles/nginx/tasks/main.yml | 9 ++++++--- roles/nginx/templates/sites/ki.conf.j2 | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 roles/nginx/files/kipasswd diff --git a/roles/nginx/files/kipasswd b/roles/nginx/files/kipasswd new file mode 100644 index 0000000..0822591 --- /dev/null +++ b/roles/nginx/files/kipasswd @@ -0,0 +1 @@ +dev:$apr1$btDCHvFb$g/e8.gemqHTdLzKBtUDjW1 diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml index 09e9ce5..66383c6 100644 --- a/roles/nginx/tasks/main.yml +++ b/roles/nginx/tasks/main.yml @@ -2,10 +2,13 @@ apt: name: nginx -- name: be sure the nginx config file is present +- name: be sure the nginx files are present copy: - src: ../files/nginx.conf - dest: /etc/nginx/nginx.conf + src: "../files/{{ item }}" + dest: "/etc/nginx/{{ item }}" + with_items: + - nginx.conf + - kipasswd - name: be sure nginx site config files are present template: diff --git a/roles/nginx/templates/sites/ki.conf.j2 b/roles/nginx/templates/sites/ki.conf.j2 index 8e290c8..0e3f52c 100644 --- a/roles/nginx/templates/sites/ki.conf.j2 +++ b/roles/nginx/templates/sites/ki.conf.j2 @@ -25,6 +25,9 @@ server { } location / { + auth_basic "KI"; + auth_basic_user_file /etc/nginx/kipasswd; + proxy_pass http://localhost:{{ ki_frontend_port }}; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr;