Skip to content

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 multiverse repository).
  • Privileges: Root access or sudo privileges are required to install system packages, manage services, and configure the firewall.
  • Architecture: The system must support the i386 architecture 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 steamcmd tool 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.so library 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:

  1. Repository Configuration: The multiverse repository is added to the system to access the steamcmd package.
  2. Architecture Setup: The i386 architecture is added to the system using dpkg --add-architecture i386.
  3. Package Installation: The steamcmd package is installed via the apt package manager.
  4. SteamCMD Binary Download: The latest steamcmd binary is downloaded from the official Steam CDN and extracted to /opt/cs2.
  5. Game File Download: The steamcmd.sh script is executed to download the Counter-Strike 2 game files (App ID 730) into the /opt/cs2/game directory.
  6. SDK Library Copy: The steamclient.so library is copied from the game installation to /root/.steam/sdk64/.
  7. Configuration Deployment: The server configuration file cs2server.cfg is placed in the game's configuration directory.
  8. Management Script Deployment: The cs2server.sh script is installed in /root to 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/letsencrypt to store SSL certificates.
  • /data/nginx/user_conf.d: Mounted to /etc/nginx/user_conf.d for 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.d directory.
  • 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_secrets mapped 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 -dedicated flag and the +exec cs2server.cfg argument.
  • 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.

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×