Skip to content

Setting up the API Linux(Debian)

Daemon Forge edited this page Jan 5, 2022 · 21 revisions

It is recomended to use a VPS(Virtual Private Server) as close as you can get to your servers, but if you have servers in multiple regions you can pick a place somewhere in the middle

If your provider doesn't offer VPSs or they are too expensive you can use my recommendation Vultr Referal Link For Vultr if use this link to get 100$ in credits for your first month, it also gives me 25$ in credits at the same time 👍

If you are using Vultr See the steps below on how to buy a VPS from Vultr If you are using another provider follow the steps below to install on Debian 10

  1. Buying a server from Vultr
  2. Setting up a Linux server
  3. Securing the Linux Server
  4. Installing the Database (MongoDB)
  5. Installing the API Service

Setting up a Linux server from Vultr(or other providers that don't have SSH enabled by default)

  • If you already have access to the server via SSH skip to Setting up continued
  • If you already know how to set up a Linux server just skip down to Installing MongoDB
  1. Add a user this way its harder for people to hack inrun adduser dayz a

and enter a secure password

  1. run adduser dayz sudo

Disable root from logging in 3. nano /etc/ssh/sshd_config

edit PermitRootLogin to be no

PermitRootLogin no 
  1. run service sshd restart

Setting up continued

Connect to the server via putty Putty Download

Run all updates sudo apt update && sudo apt upgrade -y

Securing your Linux server

  1. sudo apt install ufw

  2. sudo ufw allow ssh DON'T MISS THIS STEP

  3. sudo ufw enable enter y for yes

Installing Fail2Ban

(this is optional but recommended for larger communities that might see people trying to hack into their API)

If someone is trying to hack into it should block there IP for about 10 minutes, you can edit this in the config

  1. sudo apt install fail2ban
  2. sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
  3. sudo service fail2ban restart

Installing the Database (mongodb)

(Scroll up if you need instruction on how to set up a Linux server)

If you are using a lower core or cheaper VPS I recommend skipping the installation of MongoDB and using the free Tier of Atlas

These are the steps for installing on Debian 10 if using a different operating system reference Mongo DB official Documentaion

  1. Install sudo apt-get install -y gnupg
  2. sudo wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
  3. sudo echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
  4. sudo apt-get update
  5. sudo apt-get install -y mongodb-org
  6. sudo systemctl start mongod
  7. sudo systemctl daemon-reload
  8. sudo systemctl enable mongod
  9. sudo systemctl status mongod

Installing the API Service

  1. sudo mkdir /var/opt/DayZWebApi
  2. cd /var/opt/DayZWebApi
  3. sudo wget https://github.com/daemonforge/DayZ-UniveralApi/releases/download/Latest-Linux/dayzwebservice-linux
  4. sudo chmod +x dayzwebservice-linux
  5. sudo nano /etc/systemd/system/DayZWebService.service copy and paste the below into the terminal then ctr - x
[Unit]
Description=DayZ Webservice

[Service]
ExecStart=/var/opt/DayZWebApi/dayzwebservice-linux
Restart=always
User=root
# Note Debian/Ubuntu uses 'nogroup', RHEL/Fedora uses 'nobody'
Group=nogroup
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/var/opt/DayZWebApi

[Install]
WantedBy=multi-user.target
  1. sudo systemctl start DayZWebService
  2. sudo systemctl enable DayZWebService
  3. sudo journalctl -xe -u DayZWebService
  4. make sure you see API Webservice listening on port "443"! Go to https://localhost:443/ For your first run you should also see the default config that was generated, you can also load this by editing it by calling
  5. sudo cat /var/opt/DayZWebApi/config.json

Open the port to the API

  1. sudo ufw allow 443

Check your API

  1. reqbin.com - Change to POST and use your server https://[SERVERIP]/Status
  • if you see this then it is working!
{
    "Status": "ok",
    "Error": "noauth"
}