Deployment Overview of Counter-Strike 2 Server on Server¶
Prerequisites and Basic Requirements¶
The deployment of the Counter-Strike 2 server requires a Linux environment based on Ubuntu. The following prerequisites must be met before initiating the installation:
- Operating System: Ubuntu (any version compatible with the
multiverserepository). - Privileges: Root access or
sudoprivileges are required to install system packages, manage services, and configure the firewall. - Architecture: The system must support the
i386architecture in addition to the native architecture to ensure compatibility with Steam components. - Network: The server must have outbound internet access to download the game files and update packages.
- Ports: The server requires open ports for game traffic and web proxy services (Nginx) on ports 80 and 443.
File and Directory Structure¶
The application and its components are organized into specific directories on the server. The following paths define the location of the game binaries, configuration files, and logs:
- Game Installation Directory:
/opt/cs2 - This directory contains the
steamcmdtool and the game files. - The game binaries are located at
/opt/cs2/game. - Configuration Files:
- Server configuration:
/opt/cs2/game/game/csgo/cfg/cs2server.cfg - Management script:
/root/cs2server.sh - Steam SDK Directory:
/root/.steam/sdk64 - Contains the
steamclient.solibrary required for the server to run. - Log Files:
- Server logs are written to
/var/log/cs2server.log. - Process ID File:
- The active process ID is stored in
/tmp/cs2server.pid. - Nginx Configuration:
- User configuration directory:
/data/nginx/user_conf.d - Environment file:
/data/nginx/nginx-certbot.env - SSL secrets volume:
/etc/letsencrypt
Application Installation Process¶
The Counter-Strike 2 server is installed using the steamcmd tool, which downloads and validates the game files directly from the Steam servers. The installation process involves the following steps:
- Repository Configuration: The
multiverserepository is added to the system to access thesteamcmdpackage. - Architecture Setup: The
i386architecture is added to the system usingdpkg --add-architecture i386. - Package Installation: The
steamcmdpackage is installed via theaptpackage manager. - SteamCMD Binary Download: The latest
steamcmdbinary is downloaded from the official Steam CDN and extracted to/opt/cs2. - Game File Download: The
steamcmd.shscript is executed to download the Counter-Strike 2 game files (App ID 730) into the/opt/cs2/gamedirectory. - SDK Library Copy: The
steamclient.solibrary is copied from the game installation to/root/.steam/sdk64/. - Configuration Deployment: The server configuration file
cs2server.cfgis placed in the game's configuration directory. - Management Script Deployment: The
cs2server.shscript is installed in/rootto manage the server lifecycle.
Docker Containers and Their Deployment¶
The deployment includes a Docker container for the Nginx web server, which handles SSL termination and reverse proxying. The container is managed using a Docker Compose configuration.
- Image:
jonasal/nginx-certbot:latest - Restart Policy:
unless-stopped - Network Mode:
host - Environment Variables:
CERTBOT_EMAIL: Set to[email protected]for SSL certificate management.- Volumes:
nginx_secrets: An external volume mounted at/etc/letsencryptto store SSL certificates./data/nginx/user_conf.d: Mounted to/etc/nginx/user_conf.dfor custom Nginx configurations.- Environment File: The container loads variables from
/data/nginx/nginx-certbot.env.
The Docker Compose file is located at the root of the deployment context and defines the nginx service.
Proxy Servers¶
The Nginx container serves as the reverse proxy for the server, handling SSL/TLS encryption via Let's Encrypt.
- SSL Management: The container uses Certbot to automatically obtain and renew SSL certificates.
- Custom Domains: Custom domain configurations are managed through files placed in the
/data/nginx/user_conf.ddirectory. - Ports: The Nginx service listens on standard HTTP (80) and HTTPS (443) ports.
- Secrets Storage: SSL certificates and private keys are stored in the external volume
nginx_secretsmapped to/etc/letsencrypt.
Starting, Stopping, and Updating¶
The Counter-Strike 2 server is managed using the custom shell script located at /root/cs2server.sh. This script supports the following operations:
- Start:
- Command:
/root/cs2server.sh start - Action: Launches the server in the background using
nohup, writes the PID to/tmp/cs2server.pid, and logs output to/var/log/cs2server.log. - The server binary is executed with the
-dedicatedflag and the+exec cs2server.cfgargument. - Stop:
- Command:
/root/cs2server.sh stop - Action: Reads the PID from
/tmp/cs2server.pid, terminates the process, and removes the PID file. - Restart:
- Command:
/root/cs2server.sh restart - Action: Stops the server, waits for 2 seconds, and then starts it again.
- Status:
- Command:
/root/cs2server.sh status - Action: Checks if the PID file exists and verifies if the process is currently running.
To update the game files, the steamcmd.sh script must be executed manually with the app_update 730 validate command within the /opt/cs2 directory.