This commit is contained in:
gwen 2026-02-10 10:42:30 +01:00
parent bf3dc9c6be
commit cb25549c52

View file

@ -1,54 +1,39 @@
Pedagogic html static file server # Pedagogic html static file server
▌ 🛈 Informations > [!NOTE]
>
This is a complete Ansible playbook to configure Nginx with basic authentication using htpasswd. > This is a complete Ansible playbook to configure Nginx with basic authentication using htpasswd.\
This playbook installs Nginx, configures a static website, and secures access with basic authentication. > This playbook installs Nginx, configures a static website, and secures access with basic authentication.\
> \
▌ Steps:. > Steps:.\
> \
- Installation of Nginx: The playbook installs Nginx and ensures it is started and enabled. > - Installation of Nginx: The playbook installs Nginx and ensures it is started and enabled.\
- Creation of the website directory: A directory is created to host the website files. > - Creation of the website directory: A directory is created to host the website files.\
- Creation of a simple homepage: A simple HTML page is created for the website. > - Creation of a simple homepage: A simple HTML page is created for the website.\
- Installation of apache2-utils: This package is necessary to use the htpasswd command. > - Installation of apache2-utils: This package is necessary to use the htpasswd command.\
- Creation of the htpasswd file: A .htpasswd file is created with a username and password. > - Creation of the htpasswd file: A .htpasswd file is created with a username and password.\
- Configuration of the Nginx site: The nginx_site.conf.j2 template is used to configure Nginx with basic authentication. > - Configuration of the Nginx site: The nginx_site.conf.j2 template is used to configure Nginx with basic authentication.\
- Activation of the Nginx site: The site is enabled by creating a symbolic link in the sites-enabled directory. > - Activation of the Nginx site: The site is enabled by creating a symbolic link in the sites-enabled directory.\
- Testing the Nginx configuration: The Nginx configuration is tested before restarting the service. > - Testing the Nginx configuration: The Nginx configuration is tested before restarting the service.\
- Restarting Nginx: Nginx is restarted to apply the changes. > - Restarting Nginx: Nginx is restarted to apply the changes.\
▌ Path: nginx > **Path**: nginx
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ | Variable | Description |
┃ Variable ┃ Description ┃ |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ | **<a id="nginx.domain_name" name="nginx.domain_name">nginx.domain_name</a>**<br/>[`domainname`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | Domain name.<br/>**Validator**: type domainname<br/>**Example**: exemple.fr |
│ nginx.domain_name │ Domain name. │ | **<a id="nginx.email" name="nginx.email">nginx.email</a>**<br/>[`mail`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | Email for the domain name.<br/>This is for certbot.<br/>**Example**: contact@exemple.fr |
│ domainname mandatory │ Validator: type domainname │ | **<a id="nginx.htpasswd_file" name="nginx.htpasswd_file">nginx.htpasswd_file</a>**<br/>[`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | Htpassword file.<br/>**Validator**: file type allowed: "directory" and "file"<br/>**Default**: /etc/nginx/.htpasswd |
│ │ Example: exemple.fr │
├──────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────┤
│ nginx.email │ Email for the domain name. │
│ mail mandatory │ This is for certbot. │
│ │ Example: contact@exemple.fr │
├──────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────┤
│ nginx.htpasswd_file │ Htpassword file. │
│ UNIX filename mandatory │ Validator: file type allowed: "directory" and "file" │
│ │ Default: /etc/nginx/.htpasswd │
└──────────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────┘
users
▌ 🛈 Informations ## Nginx authenticated user credentials
▌ This family contains lists of variable blocks.
▌ Path: nginx.users
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Variable ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ nginx.users.username │
│ UNIX user multiple mandatory unique │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ nginx.users.password │
│ secret mandatory │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
> [!NOTE]
>
> This family contains lists of variable blocks.\
> **Path**: nginx.users
| Variable | Description |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|
| **<a id="nginx.users.username" name="nginx.users.username">nginx.users.username</a>**<br/>[`UNIX user`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` `mandatory` `unique` | Nginx user. |
| **<a id="nginx.users.password" name="nginx.users.password">nginx.users.password</a>**<br/>[`secret`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | Nginx password. |