Viking is a pay-per-unlock service website.
In this setup: Ubuntu will be used for the server, PostgreSQL will be used for the database, and NGINX will be used as a reverse-proxy server for Daphne.
- Make sure server is up to date. (sudo apt update && sudo apt upgrade)
- Install required packages.
apt update && apt install -y sudo software-properties-common && add-apt-repository -y ppa:maxmind/ppa && apt update && apt install -y git build-essential python3-dev python3-setuptools python-virtualenv postgresql postgresql-contrib libpq-dev redis-server rabbitmq-server postfix nginx libmaxminddb0 libmaxminddb-dev mmdb-bin
- Git clone this repository on the server into "/var/www/".
- Create a user for your database.
sudo -u postgres createuser -D -A $DB_USER - Set your database user's password.
sudo -u postgres psql -c "ALTER USER $DB_USER WITH PASSWORD '$DB_PASS';" - Create a database for Viking and give user full access.
sudo -u postgres createdb -O $DB_USER $DB_NAME
sudo -u postgres psql -c "ALTER USER $DB_USER CREATEDB;"
- Create a virtual environment in the Viking directory.
virtualenv -p $(which python3) .env
- Copy
exportsfile fromproject/viking/\_private/directory toscripts/directory. - Remove underscore from
project/viking/\_private/directory. - Make all required changes in renamed
privatedirectory. - Navigate to
scripts/directory. - Install Python packages
/viking pip install -r $(pwd)/../project/requirements.txt - Run "./viking geoip".
- Run "./viking migrate" (Verify that "axes" table was created.)
- Navigate to "/etc/nginx/sites-available".
- Create a new file named "viking_com" and symlink it to "/etc/nginx/sites-enabled".
- In that file make your nginx config. An example can be found in "_private/nginx.example".
- Generate or buy an SSL Certificate.
sudo openssl req -x509 -nodes -days 365 -out /etc/ssl/viking.crt -newkey rsa:2048 -keyout /etc/ssl/viking.key - Modify Viking's NGiNX config to point to these certs.
- Clone LetsEncrypt repo
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt - Create a ".well-known" directory.
mkdir /var/www/viking/.well-known - Uncomment LetsEncrypt section from Viking's NGiNX config.
- Comment out the Non-SSL server from the NGiNX config and restart it.
- Navigate to
/opt/letsencrypt/ - Run LetsEncrypt (Replace viking.com with your domain)
./letsencrypt-auto certonly -a webroot --webroot-path=/var/www/viking -d viking.com -d www.viking.com - Modify Viking's NGiNX config to point to these certs.
- Uncomment out the Non-SSL server from the NGiNX config and restart it.
- Edit crontab.
crontab -e - Add the follow lines for auto-renewal.
30 2 * * 1 /opt/letsencrypt/letsencrypt-auto renew >> /var/log/le-renew.log 35 2 * * 1 /bin/systemctl reload nginx
You cannot connect to an insecure websocket from a secure protocol (HTTP !-> HTTPS). Some provider's (namely AdgateMedia) HTTP notifications/postbacks do not work over HTTPS. If the above is the case for you, it is recommended to create an insecure subdomain PRIMARILY for the HTTP notifications/postbacks.
- Modify the "viking.conf" file in the "project/viking/_private/extras/" directory.
- Copy the file to "/etc/supervisor/conf.d/" directory. (Set $USER variable!)
- Reread supervisor configs
supervisorctl reread - Update supervisor apps
supervisorctl update - Start Viking
supervisorctl start viking: