mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-02-24 09:03:29 +07:00
Meilleure gestion des dossiers et htpasswd par location
This commit is contained in:
@@ -15,6 +15,19 @@
|
||||
max_conns: 150
|
||||
weight: 10
|
||||
down: false
|
||||
nginx_htpasswd:
|
||||
- name: 'hello'
|
||||
description: 'Please login!'
|
||||
users:
|
||||
- name: 'hx'
|
||||
password: 'asdfg'
|
||||
state: 'absent'
|
||||
- name: 'hanx'
|
||||
password: 'qwerty'
|
||||
- name: 'deleteme'
|
||||
description: 'Please login!'
|
||||
users: []
|
||||
state: 'absent'
|
||||
nginx_vhosts:
|
||||
- name:
|
||||
- 'test.local'
|
||||
@@ -30,6 +43,16 @@
|
||||
- 'return 403;'
|
||||
'/gunther':
|
||||
- 'return 404;'
|
||||
- name: 'test-htpasswd.local'
|
||||
template: '_base'
|
||||
location:
|
||||
'/hello':
|
||||
- htpasswd: 'hello'
|
||||
- 'default_type "text/html; charset=UTF-8";'
|
||||
- 'echo hello;'
|
||||
- name: 'test-htpasswd-all.local'
|
||||
template: '_base'
|
||||
htpasswd: 'hello'
|
||||
- name: 'test-location.local'
|
||||
template: '_base'
|
||||
location:
|
||||
@@ -78,3 +101,18 @@
|
||||
changed_when: false
|
||||
register: r
|
||||
failed_when: r.stdout.find('301 Moved Permanently') == -1
|
||||
- name: -- VERIFY AUTH BASIC NONE --
|
||||
command: "curl -H 'Host: test-htpasswd.local' http://127.0.0.1/hello"
|
||||
changed_when: false
|
||||
register: authnone
|
||||
failed_when: authnone.stdout.find('401 Authorization Required') == -1
|
||||
- name: -- VERIFY AUTH BASIC FAIL --
|
||||
command: "curl -u fail:fail -H 'Host: test-htpasswd.local' http://127.0.0.1/hello"
|
||||
changed_when: false
|
||||
register: authfail
|
||||
failed_when: authfail.stdout.find('401 Authorization Required') == -1
|
||||
- name: -- VERIFY AUTH BASIC OK --
|
||||
command: "curl -u hanx:qwerty -H 'Host: test-htpasswd.local' http://127.0.0.1/hello"
|
||||
changed_when: false
|
||||
register: authok
|
||||
failed_when: authok.stdout.find('hello') == -1
|
||||
|
||||
Reference in New Issue
Block a user