Automated deployment and security of a web server using Ansible
This project serves for automated installation and configuration of a web server using Ansible. It includes:
ansible-vault
for the secure storage of passwordsprovision.sh
for easy deployment
The project is based on static-web-test, created in the Replit environment, and was significantly enhanced with security features, automation, and system management.
The project was fully tested — provisioning was completed without errors, all services were successfully validated.ansible-web-wm
Comprehensive automation of Linux servers using Ansible, focused on:
firewall
, fail2ban
, ssh
)webapp
ansible-vault
for encrypting sensitive datainventory/hosts.ini
sudo
(for running with become: true
)git clone https://github.com/Miska296/ansible-web-wm.git
cd ansible-web-wm
export ANSIBLE_ROLES_PATH="./roles"
./provision.sh
http://localhost
or the corresponding IP address — a page with the text should be displayed:
Hello from GitHub!
This file was uploaded by Michaela for Ansible testing.ansible-vault
:
ansible-vault encrypt group_vars/web/vault
webapp_password: "tajneheslo123"
users
:
```yaml
fail2ban
is installed and activated:
```yaml
Root directory ansible-web-wm
:
Project structure in Codespace
cz For the Czech version of this documentation, see README.md
Live demo: View the project on GitHub Pages
After completing the provisioning, please perform the following checks:
systemctl status nginx
ss -tuln | grep :80
ufw status
fail2ban-client status
failed=0
confirms success.
Successful completion of provisioning (
failed=0
)
The web page has been successfully deployed and is available at the public address in GitHub Codespace: glowing-barnacle-q7xw5pvxvv4jhx6jg-80.app.github.dev
Warning: The public URL works only after the successful provisioning and publication of port 80 in the Codespace.
The displayed page after deploying NGINX
If the page displays “Hello from GitHub!”, the deployment was successful.
It shows the complete run of the script provision.sh
, deploying the web server using Ansible and verifying its functionality.
This project is based on the original repository static-web-test, where a static web application was created using the Replit platform. The project ansible-web-wm
has been supplemented with automation, security features, and extensive testing.
If ports 22 (SSH) or 80 (HTTP) are not open after provisioning, please check the following:
sudo ufw status
sudo ufw allow 22
sudo ufw allow 80
sudo ufw reload
If ports 22 or 80 are not visible in the ‘Ports’ tab:
80
and check ‘Public’https://username-repo-80.app.github.dev
listen 80
, listen [::]:80
)Check the status of the service:
systemctl status nginx
Check if it is listening on port 80:
ss -tuln | grep :80
Tip: Always verify that the port is marked as ‘Public’ in Codespace, otherwise the page won’t be accessible externally.
If you have disabled login using a password or root user, make sure you have the SSH key properly set in sshd_config
.
Try to run the provisioning again:
./provision.sh
If the webpage does not display through a public URL (e.g., in Codespace), check:
nginx.conf.j2
there is:
server_name _;
listen 80;
listen [::]:80;
localhost
.systemd
, use:
service nginx restart
sudo ufw status
DEBIAN_FRONTEND=noninteractive
to suppress interactive prompts when installing packages.ansible-vault
to securely store sensitive information.nginx
, fail2ban
, ssh
) and the open ports.server_name _
in the NGINX configuration if you want the server to respond to requests from any domain or IP address.
→ server_name localhost
restricts access to only the local machine, which may block access in environments like Codespaces or when testing from the outside.listen [::]:80;
for IPv6 support, which enhances availability in modern networks.The project was developed by Michaela Kučerová
Version: 1.0
Date: July 2025
Last updated: September 2025
Build: OK
This project is available under the MIT license. See the file LICENSE.