forked from mCaptcha/website
2.7 KiB
2.7 KiB
title | description | lead | date | lastmod | draft | images | menu | weight | toc | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Deploy bare metal | Bare metal deployment is tedious, most of this will be automated with a script in the future. | Bare metal deployment is tedious, most of this will be automated with a script in the future. | 2021-07-21 14:49 | 2021-07-21 14:49 | false |
|
120 | true |
2. Configure
mcaptcha is highly configurable.
Configuration is applied/merged in the following order:
- path to configuration file passed in via
MCAPTCHA_CONFIG
./config/default.toml
/etc/mcaptcha/config.toml
- environment variables.
1. Install postgres if you don't have it already.
For Debian based distributions:
sudo apt install postgres
2. Create new user for running mcaptcha
$ sudo useradd -b /srv -m -s /usr/bin/zsh mcaptcha
3. Create new user in Postgres
$ sudo -iu postgres # switch to `postgres` user
$ psql
postgres=# CREATE USER mcaptcha WITH PASSWORD 'my super long password and yes you need single quote`;
$ createdb -O mcaptcha mcaptcha # create db 'mcaptcha' with 'mcaptcha' as owner
4. Install and load mCaptcha/cache
module:
See mCaptcha/cache
for more
details.
4. Build mcaptcha
To build mcaptcha
, you need the following dependencies:
- rust
- node(
v14.16.0
) - yarn(JavaScript package manager)
- make
How to build
- Install Cargo using rustup with:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Install node(
v14.16.0
) -
Install yarn(JavaScript package manager)
-
Build with make:
$ make dev-env && \
make release
5. Install package:
$ sudo cp ./target/release/mcaptcha /usr/bin/ && \
mkdir sudo /etc/mcaptcha && \
sudo cp config/default.toml /etc/mcaptcha/config.toml
6. Systemd service configuration:
- Copy the following to
/etc/systemd/system/mcaptcha.service
:
[Unit]
Description=mCaptcha: a CAPTCHA system that gives attackers a run for their money
[Service]
Type=simple
User=mcaptcha
ExecStart=/usr/bin/mcaptcha
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true
Environment="RUST_LOG=info"
[Unit]
After=sound.target
Wants=network-online.target
Wants=network-online.target
Requires=postgresql.service
After=syslog.target
[Install]
WantedBy=multi-user.target
- Enable service:
$ sudo systemctl daemon-reload && \
sudo systemctl enable mcaptcha && \ # Auto startup during boot
sudo systemctl start mcaptcha
``