Skip to content

Commit 80f6157

Browse files
platangdzien
authored andcommitted
Support for configuration of basic authentication (#99)
* Support for basic authentication
1 parent 8db44bf commit 80f6157

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,17 @@ nginx_http_template:
344344
html_file_location: /usr/share/nginx/html
345345
html_file_name: index.html
346346
autoindex: false
347+
auth_basic: null
348+
auth_basic_file: null
347349
http_demo_conf: false
348350
reverse_proxy:
349351
locations:
350352
backend:
351353
location: /
352354
proxy_pass: http://backend
353355
websocket: false
356+
auth_basic: null
357+
auth_basic_file: null
354358
health_check_plus: false
355359
upstreams:
356360
upstream1:

defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,17 @@ nginx_http_template:
175175
html_file_location: /usr/share/nginx/html
176176
html_file_name: index.html
177177
autoindex: false
178+
auth_basic: null
179+
auth_basic_file: null
178180
http_demo_conf: false
179181
reverse_proxy:
180182
locations:
181183
backend:
182184
location: /
183185
proxy_pass: http://backend
184186
websocket: false
187+
auth_basic: null
188+
auth_basic_file: null
185189
health_check_plus: false
186190
upstreams:
187191
upstream1:

templates/http/default.conf.j2

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ server {
3333
{% if item.value.reverse_proxy is defined %}
3434
{% for location in item.value.reverse_proxy.locations %}
3535
location {{ item.value.reverse_proxy.locations[location].location }} {
36+
{% if item.value.reverse_proxy.locations[location].auth_basic is defined and item.value.reverse_proxy.locations[location].auth_basic %}
37+
auth_basic "{{ item.value.reverse_proxy.locations[location].auth_basic }}";
38+
{% endif %}
39+
{% if item.value.reverse_proxy.locations[location].auth_basic_file is defined and item.value.reverse_proxy.locations[location].auth_basic_file %}
40+
auth_basic_user_file {{ item.value.reverse_proxy.locations[location].auth_basic_file }};
41+
{% endif %}
3642
proxy_pass {{ item.value.reverse_proxy.locations[location].proxy_pass }};
3743
{% if item.value.reverse_proxy.health_check_plus is defined and item.value.reverse_proxy.health_check_plus %}
3844
health_check;
@@ -56,6 +62,12 @@ server {
5662
index {{ item.value.web_server.locations[location].html_file_name }};
5763
{% if item.value.web_server.locations[location].autoindex %}
5864
autoindex on;
65+
{% endif %}
66+
{% if item.value.web_server.locations[location].auth_basic is defined and item.value.web_server.locations[location].auth_basic %}
67+
auth_basic "{{ item.value.web_server.locations[location].auth_basic }}";
68+
{% endif %}
69+
{% if item.value.web_server.locations[location].auth_basic_file is defined and item.value.web_server.locations[location].auth_basic_file %}
70+
auth_basic_user_file {{ item.value.web_server.locations[location].auth_basic_file }};
5971
{% endif %}
6072
}
6173
{% endfor %}

0 commit comments

Comments
 (0)