Skip to content

Configuration

PhlexPlexico edited this page Jul 31, 2022 · 11 revisions

In order to configure the application, there are a few .template files located under ./config. These files are meant to assist in a quick setup. In order to run the application in a given environment, please copy the file and rename it to development/test/production.json dependent on what environment you wish to run. Here is the example in question for development:

{
  "server": {
    "port": 3301,
    "hostname": "http://localhost",
    "dbKey": "Database 16 Byte Key.",
    "steamAPIKey": "API Key For Steam Calls.",
    "sharedSecret": "a secure secret for jwt sigining.",
    "clientHome": "http://localhost:8080",
    "useRedis": true,
    "apiURL": "http://localhost:8080/api",
    "uploadDemos": false,
    "localLoginEnabled": true
  },
  "development": {
    "driver": "mysql",
    "user": "get5_user",
    "password": "",
    "database": "get5dev",
    "multipleStatements": true,
    "flags": { "ENV": "MYSQL_FLAGS" },
    "host": "127.0.0.1",
    "port": 3306,
    "connectionLimit": 15,
    "redisUrl": "redis://:super_secure@localhost:6379",
    "redisTTL": 86400
  },
  "admins": {
    "steam_ids": "admins,go,here"
  },
  "super_admins": {
    "steam_ids": "super_admins,go,here"
  }
}

We'll go through section-by-section to determine what is needed to change, and what isn't.

Server

Inside the server block, you will see a few options. The port is reference to where the API will bind itself to. The default I left was 3301. You may change this to whatever you like, so long as it isn't conflicting with other applications, such as Apache/Tomcat.

Next is the hostname. Since get5 requires a valid hostname, you can not simply use an IP. Please register a domain, or use something like DuckDNS to create a hostname!

The dbKey field is a 16 byte key used to generate some security for storing RCON passwords in the database. I recommend using Random.org to generate a 16 byte hexadecimal value, and stripping the whitespace between the numbers.

The steamAPIKey is the developer API key that you must retrieve from Steam. Just paste this key within the quotes.

The sharedSecret is used to save sessions to a cookie. Make sure you make this as unique as possible to avoid anyone gaining unauthorized user access.

The clientHome is a URL to use on redirects during authentication. This is what your front-end URL is supposed to be. In this case, G5V uses localhost:8080 to run its development server on, so it is set to that. If you wish to use this over the network, and not just your machine, set it to your front-ends local IP address. CORS is also enabled for that URL specifically, to prevent any unauthorized usage of the API.

The useRedis option (true/false) is mainly used for setup and config. Depending on your setup, you may not be able to run a redis instance for session storage. Just switch this to false, and you will be able to use the applications session storage. This is not recommended however, so please make sure you get a redis-server running.

The apiURL portion in the config is the URL that is going to be sent to the counter-strike servers. Please set this as a direct link to your API. Be it through a reverse proxy (via nginx, webpack, etc), or a direct link to the API, where the welcome page is displayed (i.e. message: "Welcome to G5API!" upon login).

The uploadDemos option is a boolean value to enable demo uploading from a game server to your API server. However, since demos tend to be rather large, there is also some configuration you have to enable in your nginx/caddy/apache instance if you are using a reverse proxy. This must be done on the reverse proxy. Whether that is on the same server as G5API or not is completely up to your setup.

  • For NGINX, the default value should be this in /etc/nginx/sites-enabled/default inside the server block - client_max_body_size 256M; 128MB should be sufficient, but this is in case a demo is ridiculously large.
  • For Caddy you will have to create another block inside your server to have the following:
request_body {
  max_size 256MB
}
  • For apache it should already be defaulted to 0 (unlimited). If there is a problem with it, you can limit it in either the .htaccess file or httpd.conf file with the following syntax:
<Directory "/path/to/G5API/public/">
	LimitRequestBody  256000000
</Directory>

Remember, these settings may not be needed for the latter two web servers, and this would be only required if you are using a reverse proxy to the API. If you are using direct access (i.e. https://yourget5site.com:3301), you should not need any of these changes since you are using node, and not a web server that forwards the requests to the API.

The localLoginEnabled is a config call that will either enable or disable "local" (i.e. no steam Login) registration and sign in. This feature is mainly used for LAN events that try to Firewall off as much as possible. The API itself requires a Steam Connection for a few things, but should still be operable without.

Development/Test/Production

This block of configuration is where all the database information goes. The main thing you have to worry about during setup is the following:

user is the user that you had created in steps prior. If you followed the wiki, this would be get5_user.

password is the password you created at the time of creating the database user as well, paste that password in there.

database, depending on what file/environment you use, this will be either get5dev, get5test, or get5.

host is dependent on wherever your database is hosted. If on a separate server, please fill in the correct IP. If it is running on the same machine, leave it as is.

port is only changed if you have changed the default port of your mysql installation. Leave it as is if you have not.

redisUrl is the same as host above. Leave if it Redis is installed on the machine running the API. However, the password should most definitely be changed. This password that you placed in the redis.conf file on your system should be where super_secure is, past the colon.

Admins/Super Admins

These last two sections both take Steam64 IDs that are separated by commas. A super admin will have access to RCON passwords of all the servers, and would be able to run any RCON commands against a game server as well. An admin has a bit less access, but should be able to cancel matches, edit teams, etc.

Apply database configs

Depending on the environment, setup will change based on the environment keyword. It's all taken care of as something the package.json. So, for example if you're running a production build, simply run the following commands:

yarn migrate-create-prod
yarn migrate-prod-upgrade

If you have created the database already (per instructions in the installation notes), you will only need to run the following command:

yarn migrate-prod-upgrade

Then you are all set!

Starting the app

Once this is all setup, run yarn to get all the dependencies, set your NODE_ENV and then yarn startprod! The API will be up and running!

Clone this wiki locally