Skip to content

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:

  1. Directory Creation: The system creates the necessary directory structure under /data/nginx/ with specific permissions (0640).

  2. Host Configuration: An entry is added to /etc/hosts to map the local FQDN to 127.0.0.1.

  3. Configuration Generation:

  4. A Docker Compose file is generated at /data/nginx/docker-compose.yml.

  5. A custom Nginx configuration file is generated in /data/nginx/user_conf.d/ based on the server's FQDN.

  6. Environment Setup: An environment file nginx-certbot.env is placed in the application directory to manage SSL certificate automation.

  7. Volume Creation: A Docker volume named nginx_secrets is created to persist SSL certificates.

  8. Service Deployment: The containers are started using docker compose up -d from within the /data/nginx/ directory.

Access Rights and Security

  • File Permissions: Configuration files and directories are owned by root:root with restricted access (0640 for directories and 0644 for 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:

cd /data/nginx/
docker compose pull && docker compose up -d
question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×