website/docs/self-hosting/bare-metal/index.html

351 lines
18 KiB
HTML

<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="preload" as="font" href="/fonts/vendor/jost/jost-v4-latin-regular.woff2" type="font/woff2" crossorigin>
<link rel="preload" as="font" href="/fonts/vendor/jost/jost-v4-latin-700.woff2" type="font/woff2" crossorigin>
<link rel="stylesheet" href="/main.daf9ee98168127ebe801fa49abea19e9b93a1e6615b5fb8613d39531c652f02d2d15c7680cf20e2047c2887b04f2192dc9a7847c62393718246d9f3e634a4e4d.css" integrity="sha512-2vnumBaBJ&#43;voAfpJq&#43;oZ6bk6HmYVtfuGE9OVMcZS8C0tFcdoDPIOIEfCiHsE8hktyaeEfGI5NxgkbZ8&#43;Y0pOTQ==" crossorigin="anonymous">
<noscript><style>img.lazyload { display: none; }</style></noscript>
<meta name="robots" content="index, follow">
<meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1">
<meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1">
<title>Deploy bare metal - mCaptcha</title>
<meta name="description" content="Bare metal deployment is tedious, most of this will be automated with a script in the future.">
<link rel="canonical" href="/docs/self-hosting/bare-metal/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="/icon.png">
<meta name="twitter:title" content="Deploy bare metal">
<meta name="twitter:description" content="Bare metal deployment is tedious, most of this will be automated with a script in the future.">
<meta name="twitter:site" content="@">
<meta name="twitter:creator" content="@">
<meta property="og:title" content="Deploy bare metal">
<meta property="og:description" content="Bare metal deployment is tedious, most of this will be automated with a script in the future.">
<meta property="og:type" content="article">
<meta property="og:url" content="/docs/self-hosting/bare-metal/">
<meta property="og:image" content="/icon.png"/>
<meta property="article:modified_time" content="2024-01-08T00:31:40+05:30">
<meta property="og:site_name" content="mCaptcha">
<meta property="article:publisher" content="https://www.facebook.com/">
<meta property="article:author" content="https://www.facebook.com/">
<meta property="og:locale" content="en_US">
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1 ,
"name": "Home",
"item": "\/"
},{
"@type": "ListItem",
"position": 2 ,
"name": "Docsself Hostingbare Metal",
"item": "\/docsself-hostingbare-metal\/"
}]
}
</script>
<meta name="theme-color" content="#fff">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
</head>
<body class="docs single">
<div class="header-bar fixed-top"></div>
<header class="navbar fixed-top navbar-expand-md navbar-light">
<div class="container">
<input class="menu-btn order-0" type="checkbox" id="menu-btn">
<label class="menu-icon d-md-none" for="menu-btn"><span class="navicon"></span></label>
<a class="navbar-brand order-1 order-md-0 me-auto" href="/">mCaptcha</a>
<button id="mode" class="btn btn-link order-2 order-md-4" type="button" aria-label="Toggle mode">
<span class="toggle-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg></span>
<span class="toggle-light"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-sun"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg></span>
</button>
<ul class="navbar-nav social-nav order-3 order-md-5">
<li class="nav-item">
<a class="nav-link" href="https://github.com/mCaptcha"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-github"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path></svg><span class="ms-2 visually-hidden">GitHub</span></a>
</li>
</ul>
<div class="collapse navbar-collapse order-4 order-md-1">
<ul class="navbar-nav main-nav me-auto order-5 order-md-2"><li class="nav-item">
<a class="nav-link" href="/blog/">Blog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/community/">Community</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact/">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/about/">About</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/docs/webmasters/installing-captcha/">Docs</a>
</li>
</ul>
<div class="break order-6 d-md-none"></div>
<form class="navbar-form flex-grow-1 order-7 order-md-3">
<input id="userinput" class="form-control is-search" type="search" placeholder="Search docs..." aria-label="Search docs..." autocomplete="off">
<div id="suggestions" class="shadow bg-white rounded"></div>
</form>
</div>
</div>
</header>
<div class="wrap container" role="document">
<div class="content">
<div class="row flex-xl-nowrap">
<div class="col-lg-5 col-xl-4 docs-sidebar">
<nav class="docs-links" aria-label="Main navigation">
<h3>Webmasters</h3>
<ul class="list-unstyled">
<li><a class="docs-link" href="/docs/webmasters/installing-captcha/">Installing mCaptcha on your website</a></li>
<li><a class="docs-link" href="/docs/webmasters/configuring-difficulty-factor/">Configuring Difficulty Factor</a></li>
<li><a class="docs-link" href="/docs/webmasters/terminology/">Terminology</a></li>
<li><a class="docs-link" href="/docs/webmasters/faq/">Webmasters FAQ</a></li>
</ul>
<h3>User Manual</h3>
<ul class="list-unstyled">
<li><a class="docs-link" href="/docs/user-manual/cli/">CLI tool</a></li>
<li><a class="docs-link" href="/docs/user-manual/how-to-mcaptcha-without-js/">Use mCaptcha without JavaScript</a></li>
</ul>
<h3>Self-Hosting</h3>
<ul class="list-unstyled">
<li><a class="docs-link" href="/docs/self-hosting/getting-started/">Getting started</a></li>
<li><a class="docs-link active" href="/docs/self-hosting/bare-metal/">Deploy bare metal</a></li>
<li><a class="docs-link" href="/docs/self-hosting/ansible/">Using Ansible</a></li>
<li><a class="docs-link" href="/docs/self-hosting/docker/">Using Docker</a></li>
</ul>
<h3>API</h3>
<ul class="list-unstyled">
<li><a class="docs-link" href="/docs/api/browser/">Browser libraries</a></li>
<li><a class="docs-link" href="/docs/api/mcaptcha-system/">mCaptcha System Library</a></li>
<li><a class="docs-link" href="/docs/api/pow-sha256/">pow_sha256</a></li>
</ul>
<h3>Help</h3>
<ul class="list-unstyled">
<li><a class="docs-link" href="/docs/help/troubleshooting/">Troubleshooting</a></li>
<li><a class="docs-link" href="/docs/help/faq/">FAQ</a></li>
</ul>
</nav>
</div>
<nav class="docs-toc d-none d-xl-block col-xl-3" aria-label="Secondary navigation">
<div class="page-links">
<h3>On this page</h3>
<nav id="TableOfContents">
<ul>
<li><a href="#1-install-database">1. Install Database</a></li>
<li><a href="#2-optionally-install-mcaptchacache">2. Optionally, install mCaptcha/cache</a></li>
<li><a href="#3-install-mcaptcha">3. Install mCaptcha</a>
<ul>
<li><a href="#31-install-from-source">3.1 Install from source</a></li>
<li><a href="#32-install-pre-compiled-binary">3.2 Install pre-compiled binary</a></li>
<li><a href="#ii-verify-checksum">ii Verify checksum</a></li>
<li><a href="#iii-verify-gpg-signature">iii Verify GPG signature</a></li>
<li><a href="#iv-install">iv. Install</a></li>
<li><a href="#4-configuration">4. Configuration</a></li>
<li><a href="#5-systemd-service-configuration">5. Systemd service configuration:</a></li>
<li><a href="#6-install-and-configure-nginx">6. Install and configure Nginx</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</nav>
<main class="docs-content col-lg-11 col-xl-9">
<h1>Deploy bare metal</h1>
<p class="lead">Bare metal deployment is tedious, most of this will be automated with a script in the future.</p>
<h2 id="1-install-database">1. Install Database<a href="#1-install-database" class="anchor" aria-hidden="true">#</a> </h2>
<p>The following databases are supported:</p>
<ol>
<li>Postgres</li>
<li>MariaDB</li>
</ol>
<p>Please install the database of your choice. Then:</p>
<ol>
<li>Create new database user for mCaptcha</li>
<li>Create new database for mCaptcha</li>
</ol>
<p>mCaptcha binary has migrations baked-in and is applied on start up. The
choice of database is described using the <a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#scheme">scheme</a> of the database URL. For
instance:</p>
<ol>
<li>Postgres: <code>postgres://mcaptcha:password@localhost:5432/mcaptcha</code></li>
<li>Mariadb: <code>mysql://mcaptcha:password@localhost:3306/mcaptcha</code></li>
</ol>
<h2 id="2-optionally-install-mcaptchacache">2. Optionally, install mCaptcha/cache<a href="#2-optionally-install-mcaptchacache" class="anchor" aria-hidden="true">#</a> </h2>
<p>We recommend this for larger instances. For single-user instances or for
instances that protect personal websites, we recommend using the
internal cache system. To do so, please comment out the
<a href="https://github.com/mCaptcha/mCaptcha/blob/d4967626ee59504b32b0f85e409b4e3444ddc4f0/config/default.toml#L54"><code>redis</code></a> section of the configuration file.</p>
<p>Please see <a href="https://github.com/mCaptcha/cache"><code>mCaptcha/cache</code></a> for more details.</p>
<h2 id="3-install-mcaptcha">3. Install mCaptcha<a href="#3-install-mcaptcha" class="anchor" aria-hidden="true">#</a> </h2>
<h3 id="31-install-from-source">3.1 Install from source<a href="#31-install-from-source" class="anchor" aria-hidden="true">#</a> </h3>
<p>To build <code>mcaptcha</code>, you need the following dependencies:</p>
<ol>
<li>rust</li>
<li>node(<code>v20</code>)</li>
<li>yarn(JavaScript package manager)</li>
<li>make</li>
</ol>
<p>With all dependencies installed, run:</p>
<pre tabindex="0"><code>make dev-env &amp;&amp; make release
</code></pre><p>And the following commands to install the compiled binary:</p>
<pre tabindex="0"><code>sudo cp ./target/release/mcaptcha /usr/bin/ &amp;&amp; \
mkdir sudo /etc/mcaptcha &amp;&amp; \
sudo cp config/default.toml /etc/mcaptcha/config.toml
</code></pre><h3 id="32-install-pre-compiled-binary">3.2 Install pre-compiled binary<a href="#32-install-pre-compiled-binary" class="anchor" aria-hidden="true">#</a> </h3>
<h4 id="i-download-assets">i. Download assets<a href="#i-download-assets" class="anchor" aria-hidden="true">#</a> </h4>
<pre tabindex="0"><code>wget https://dl.mcaptcha.org/mcaptcha/mCaptcha/master/mcaptcha-master-linux-amd64.tar.gz.asc
wget https://dl.mcaptcha.org/mcaptcha/mCaptcha/master/mcaptcha-master-linux-amd64.tar.gz.sha256
wget https://dl.mcaptcha.org/mcaptcha/mCaptcha/master/mcaptcha-master-linux-amd64.tar.gz
</code></pre><h3 id="ii-verify-checksum">ii Verify checksum<a href="#ii-verify-checksum" class="anchor" aria-hidden="true">#</a> </h3>
<pre tabindex="0"><code>sha256sum -c mcaptcha-master-linux-amd64.tar.gz.sha256
</code></pre><h3 id="iii-verify-gpg-signature">iii Verify GPG signature<a href="#iii-verify-gpg-signature" class="anchor" aria-hidden="true">#</a> </h3>
<p>All mcaptcha binaries are signed with <a href="https://keyserver.ubuntu.com/pks/lookup?search=73DAC973A9ADBB9ADCB5CDC4595A08135BA9FF73&amp;fingerprint=on&amp;op=index">our GPG
key</a>.
Please verify signatures to verify authenticity.</p>
<pre tabindex="0"><code>gpg --keyserver keyserver.ubuntu.com --recv 73DAC973A9ADBB9ADCB5CDC4595A08135BA9FF73
gpg --verify mcaptcha-master-linux-amd64.tar.gz.asc
</code></pre><h3 id="iv-install">iv. Install<a href="#iv-install" class="anchor" aria-hidden="true">#</a> </h3>
<pre tabindex="0"><code>tar -xvzf mcaptcha-master-linux-amd64.tar.gz \
&amp;&amp; sudo cp mcaptcha-master-linux-amd64/mcaptcha /usr/local/bin \
&amp;&amp; sudo mkdir /etc/mcaptcha \
&amp;&amp; sudo cp mcaptcha-master-linux-amd64/config.toml /etc/mcaptcha/
</code></pre><h3 id="4-configuration">4. Configuration<a href="#4-configuration" class="anchor" aria-hidden="true">#</a> </h3>
<p>mCaptcha is highly configurable.</p>
<p>Configuration is applied/merged in the following order:</p>
<ol>
<li>path to configuration file passed in via <code>MCAPTCHA_CONFIG</code></li>
<li><code>./config/default.toml</code></li>
<li><code>/etc/mcaptcha/config.toml</code></li>
<li>environment variables. Please see
<a href="https://github.com/mCaptcha/mCaptcha/blob/master/docs/CONFIGURATION.md">here</a> for a full list of environment variables.</li>
</ol>
<h3 id="5-systemd-service-configuration">5. Systemd service configuration:<a href="#5-systemd-service-configuration" class="anchor" aria-hidden="true">#</a> </h3>
<ol>
<li>Copy the following to <code>/etc/systemd/system/mcaptcha.service</code>:</li>
</ol>
<pre tabindex="0"><code>[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=&#34;RUST_LOG=info&#34;
[Unit]
After=sound.target
Wants=network-online.target
Wants=network-online.target
Requires=postgresql.service
After=syslog.target
[Install]
WantedBy=multi-user.target
</code></pre><ol start="2">
<li>Enable service:</li>
</ol>
<pre tabindex="0"><code>sudo systemctl daemon-reload &amp;&amp; \
sudo systemctl enable mcaptcha &amp;&amp; \ # Auto startup during boot
sudo systemctl start mcaptcha
</code></pre><h3 id="6-install-and-configure-nginx">6. Install and configure Nginx<a href="#6-install-and-configure-nginx" class="anchor" aria-hidden="true">#</a> </h3>
<p>mCaptcha doesn&rsquo;t implement SSL yet. Please use a reverse proxy like
Nginx to add SSL to your deployment. Here&rsquo;s an example virtual host
configuration for Nginx:</p>
<pre tabindex="0"><code>server {
server_name &lt;your mcaptcha hostname&gt;;
listen 80;
listen [::]:80;
location / {
proxy_pass http://127.0.0.1:&lt;mcaptcha_port&gt;;
proxy_set_header Host $host;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection &#34;upgrade&#34;;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
</code></pre>
<p class="edit-page"><a href="https://git.batsense.net/mCaptcha/website/blob/master/content/docs/self-hosting/bare-metal.md"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>Edit this page on git.batsense.net</a></p>
<div class="docs-navigation d-flex justify-content-between">
<a href="/docs/self-hosting/getting-started/">
<div class="card my-1">
<div class="card-body py-2">
&larr; Getting started
</div>
</div>
</a>
<a class="ms-auto" href="/docs/self-hosting/ansible/">
<div class="card my-1">
<div class="card-body py-2">
Using Ansible &rarr;
</div>
</div>
</a>
</div>
</main>
</div>
</div>
</div>
<footer class="footer text-muted">
<div class="container">
<div class="row">
<div class="col-lg-8 order-last order-lg-first">
<ul class="list-inline">
<li class="list-inline-item">Powered by <a href="https://gohugo.io/">Hugo</a>, and <a href="https://getdoks.org/">Doks</a></li>
</ul>
</div>
<div class="col-lg-8 order-first order-lg-last text-lg-end">
<ul class="list-inline">
<li class="list-inline-item"><a href="/about/">About</a></li>
<li class="list-inline-item"><a href="/donate">Donate</a></li>
<li class="list-inline-item"><a href="/privacy-policy/">Privacy</a></li>
<li class="list-inline-item"><a href="/security">Security</a></li>
<li class="list-inline-item"><a href="https://stats.uptimerobot.com/GK7VLFJnBl">Status</a></li>
<li class="list-inline-item"><a href="/thanks">Thanks</a></li>
</ul>
</div>
</div>
</div>
</footer>
<script src="/main.min.3ee0ac4f86a3696df8d8100a6b908e1d916e5ba581515d6ca65d6849444faf247f83e42d5c7e31046edd28842ddb5369bc072c42486b426dc54057495ba99e97.js" integrity="sha512-PuCsT4ajaW342BAKa5COHZFuW6WBUV1spl1oSURPryR/g&#43;QtXH4xBG7dKIQt21NpvAcsQkhrQm3FQFdJW6melw==" crossorigin="anonymous" defer></script>
<script src="/index.min.93b8a8c2342494612b6248052a9ee91028f73ecaca031e57b8e7bdbf1b6bea8ac3cc0db982f0bd4450facb3921041ff2c4f8c2ea5b8372142777b552db3f5167.js" integrity="sha512-k7iowjQklGErYkgFKp7pECj3PsrKAx5XuOe9vxtr6orDzA25gvC9RFD6yzkhBB/yxPjC6luDchQnd7VS2z9RZw==" crossorigin="anonymous" defer></script>
</body>
</html>