Deployment Overview of Nginx on Server¶
Prerequisites and Basic Requirements¶
To ensure a successful deployment, the following requirements must be met:
-
Operating System: Debian or Ubuntu.
-
Privileges: Root or sudo access is required for directory creation and service management.
-
Docker: Docker and Docker Compose must be installed on the host system.
-
Network Ports: The following ports must be open in the firewall to allow web traffic:
-
80/TCP(HTTP) -
443/TCP(HTTPS)
FQDN of the final panel on the hostkey.in domain¶
The application uses a specific naming convention for its Fully Qualified Domain Name (FQDN). The template is defined as follows:
| Parameter | Value |
|---|---|
| Prefix | nginx |
| Domain | hostkey.in |
| Full template | nginx{Server_ID}.hostkey.in |
File and Directory Structure¶
The application data and configurations are stored in the following locations:
-
/data/nginx/: Main application directory. -
/data/nginx/docker-compose.yml: Docker Compose configuration file. -
/data/nginx/user_conf.d/: Directory containing custom Nginx server configurations. -
/data/nginx/nginx-certbot.env: Environment variables for the container.
Application installation process¶
The application is deployed using a combination of system directory setup and Docker Compose. The installation follows these steps:
-
Directory Creation: The system creates the necessary directory structure under
/data/nginx/with specific permissions (0640). -
Host Configuration: An entry is added to
/etc/hoststo map the local FQDN to127.0.0.1. -
Configuration Generation:
-
A Docker Compose file is generated at
/data/nginx/docker-compose.yml. -
A custom Nginx configuration file is generated in
/data/nginx/user_conf.d/based on the server's FQDN. -
Environment Setup: An environment file
nginx-certbot.envis placed in the application directory to manage SSL certificate automation. -
Volume Creation: A Docker volume named
nginx_secretsis created to persist SSL certificates. -
Service Deployment: The containers are started using
docker compose up -dfrom within the/data/nginx/directory.
Access Rights and Security¶
-
File Permissions: Configuration files and directories are owned by
root:rootwith restricted access (0640for directories and0644for files). -
Firewall: Only ports 80 and 443 are required to be exposed.
-
SSL/TLS: The deployment is configured to use Let's Encrypt via Certbot for secure HTTPS communication.
Docker Containers and Their Deployment¶
The application runs within a single container managed by Docker Compose:
| Container Name | Image | Ports | Volumes | Environment Variables | Restart Policy |
|---|---|---|---|---|---|
nginx | jonasal/nginx-certbot:latest | 80:80, 443:443 | - nginx_secrets:/etc/letsencrypt- ./user_conf.d:/etc/nginx/user_conf.d | [email protected] (via .env file) | unless-stopped |
Application Update Instructions¶
To update the Nginx application, navigate to the application directory and pull the latest images: