You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.3 KiB
Markdown
35 lines
1.3 KiB
Markdown
|
5 months ago
|
# Nginx Server installer
|
||
|
|
|
||
|
|
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.
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
- have a look at the hosts_vars:
|
||
|
|
|
||
|
|
cat host_vars/mistergwen.site.yml
|
||
|
|
domain_name: "mistergwen.site"
|
||
|
|
htpasswd_file: "/etc/nginx/.htpasswd"
|
||
|
|
...
|
||
|
|
|
||
|
|
- then launch the deployment script:
|
||
|
|
|
||
|
|
./deploy.sh
|
||
|
|
|
||
|
|
## Steps
|
||
|
|
|
||
|
|
- 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 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.
|
||
|
|
- 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.
|
||
|
|
- 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.
|
||
|
|
- Restarting Nginx: Nginx is restarted to apply the changes.
|
||
|
|
|
||
|
|
## TODO
|
||
|
|
|
||
|
|
- use ansible vault for the user's credentials
|
||
|
|
|