Nginx + MariaDB + MyAAC

1 - Installation - Nginx:

Nginx
sudo apt update && sudo apt upgrade -y
sudo apt install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl status nginx
  • How to test: http://server-ip

2 - Installation - MariaDB:

MariaDB
sudo apt install -y mariadb-server mariadb-client
sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo systemctl status mariadb

sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

When you're done, test if you can log into the MariaDB console by typing: 

sudo mariadb
 
This will connect to the MariaDB server as the database root administrative user, which is assumed by using sudo when running this command.

You should see a result like this: 

"Output
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 32
Server version: 10.6.12-MariaDB-0Ubuntu0.22.04.1 Ubuntu 22.04

Copyright (c) 2000, 2018, Oracle, MariaDb Corporation and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

To exit the MariaDB console, type:  exit

MariaDB [(none)]> exit

3 - Configuration - MariaDB User:

Configuration - MariaDB User
  • If you have root user-enabled password authentication, you will need to run the following command and enter your password when prompted to be able to connect:

sudo mariadb -u root -p
  • From there, create a new user and give them a strong password:

CREATE USER 'your_user'@'localhost' IDENTIFIED BY 'your_password';
  • Then grant your new user the appropriate privileges. For example, you can grant user privileges to all tables within the database, in addition to the power to add, change, and remove user privileges, with this command:

GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'localhost' WITH GRANT OPTION;โ€Š
  • After that, exit the MariaDB shell:

exit

4 - Installation - PHP:

PHP

5 - Installation - phpMyAdmin:

phpMyAdmin
  • How to test: http://server-ip/phpmyadmin

  • How to restrict phpMyAdmin access:

sudo mv /var/www/html/phpmyadmin /var/www/html/any_combination_youwant

โ€ข Change any_combination_youwant for a word that only you know.

โ€ข Then you will access phpMyAdmin by: http://server-ip/any_combination_youwant

6 - Configuration - Nginx:

Configuration - Nginx
  • In the terminal type the following command:

  • Once installed we will configure Nginx, then in the terminal enter the following command:

  • Configure leaving it this way:

-

7 - Database:

  • Go to phpMyAdmin.

  • On the left side click +New and create a database (e.g. canary)

  • Import the schema.sql that is in the server folder.

8 - Config.lua:

For data-canary
For data-otservbr-global

9 - Installation - MyAAC:

MyAAC
  • Install MyAAC: http://domain-or-ip/install;

  • Follow the installation steps;

10 - Firewall:

Firewall

11 - Releasing Ports - Google Cloud / Oracle:

Releasing Ports - Google Cloud / Oracle

12 - Starting the Server:

Starting the Server

You will need the installed screen:

sudo apt install screen

12.1 - Basic screen commands:

  • Open a screen:

  • Exit a screen:

  • Back to the last open screen:

  • Close a screen:

  • Info:

13 - Connecting to the Server:

If you changed the port to 8080 or 8090, remember to add it in the normal client or otclient redemption.

14 - Useful Tips:

  • Use this example nginx file with security checks to protect your configurations.

Nginx

15 - Credits:

Last updated