Deploy bare metal
Bare metal deployment is tedious, most of this will be automated with a script in the future.
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:
1sudo apt install postgres
2. Create new user for running mcaptcha
1$ sudo useradd -b /srv -m -s /usr/bin/zsh mcaptcha
3. Create new user in Postgres
1$ sudo -iu postgres # switch to `postgres` user
2$ psql
3postgres=# CREATE USER mcaptcha WITH PASSWORD 'my super long password and yes you need single quote`;
4$ 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:
1$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Install node(
v14.16.0
) -
Install yarn(JavaScript package manager)
-
Build with make:
1$ make dev-env && \
2 make release
5. Install package:
1$ sudo cp ./target/release/mcaptcha /usr/bin/ && \
2 mkdir sudo /etc/mcaptcha && \
3 sudo cp config/default.toml /etc/mcaptcha/config.toml
6. Systemd service configuration:
- Copy the following to
/etc/systemd/system/mcaptcha.service
:
1[Unit]
2Description=mCaptcha: a CAPTCHA system that gives attackers a run for their money
3
4[Service]
5Type=simple
6User=mcaptcha
7ExecStart=/usr/bin/mcaptcha
8Restart=on-failure
9RestartSec=1
10SuccessExitStatus=3 4
11RestartForceExitStatus=3 4
12SystemCallArchitectures=native
13MemoryDenyWriteExecute=true
14NoNewPrivileges=true
15Environment="RUST_LOG=info"
16
17[Unit]
18After=sound.target
19Wants=network-online.target
20Wants=network-online.target
21Requires=postgresql.service
22After=syslog.target
23
24[Install]
25WantedBy=multi-user.target
- Enable service:
1$ sudo systemctl daemon-reload && \
2 sudo systemctl enable mcaptcha && \ # Auto startup during boot
3 sudo systemctl start mcaptcha
4``