website/content/docs/self-hosted/bare-metal.md
2021-07-21 15:49:53 +05:30

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
docs
parent
self-hosted
120 true

2. Configure

mcaptcha is highly configurable.

Configuration is applied/merged in the following order:

  1. path to configuration file passed in via MCAPTCHA_CONFIG
  2. ./config/default.toml
  3. /etc/mcaptcha/config.toml
  4. 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:

  1. rust
  2. node(v14.16.0)
  3. yarn(JavaScript package manager)
  4. make

How to build

  1. Install Cargo using rustup with:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Install node(v14.16.0)

  2. Install yarn(JavaScript package manager)

  3. 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:

  1. 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
  1. Enable service:
$ sudo systemctl daemon-reload && \
	sudo systemctl enable mcaptcha && \ # Auto startup during boot
	sudo systemctl start mcaptcha
``