diff options
| -rw-r--r-- | auth.html | 6 | ||||
| -rw-r--r-- | bat.html | 4 | ||||
| -rw-r--r-- | bitcoin.html | 4 | ||||
| -rw-r--r-- | certbot.html | 6 | ||||
| -rw-r--r-- | cgi.html | 268 | ||||
| -rw-r--r-- | cron.html | 44 | ||||
| -rw-r--r-- | dns.html | 9 | ||||
| -rw-r--r-- | domain.html | 4 | ||||
| -rw-r--r-- | gemini.html | 4 | ||||
| -rw-r--r-- | gitea.html | 2 | ||||
| -rw-r--r-- | html.html | 4 | ||||
| -rw-r--r-- | index.html | 16 | ||||
| -rw-r--r-- | irc.html | 22 | ||||
| -rw-r--r-- | matrix.html | 87 | ||||
| -rw-r--r-- | monero.html | 2 | ||||
| -rw-r--r-- | nextcloud.html | 13 | ||||
| -rw-r--r-- | nginx.html | 8 | ||||
| -rw-r--r-- | openalias.html | 2 | ||||
| -rw-r--r-- | rss-bridge.html | 98 | ||||
| -rw-r--r-- | rss.xml | 497 | ||||
| -rw-r--r-- | rsync.html | 55 | ||||
| -rw-r--r-- | server.html | 4 | ||||
| -rw-r--r-- | ufw.html | 2 | ||||
| -rw-r--r-- | xmpp.html | 87 |
24 files changed, 1131 insertions, 117 deletions
@@ -21,8 +21,8 @@ <p>We will be using the command <code>htpasswd</code> to make username and password pairs.</p> <pre><code>apt install apache2-utils</code></pre> <aside> - <p>The apache utils has a small username-password pair encryption tool.</p> - <p>Like the other on this site, this tutorial is for Nginx, <strong>not</strong> for Apache servers.</p> + <p>The apache utils include a small username-password pair encryption tool.</p> + <p>Like the other tutorials on this site, this tutorial is for Nginx, <strong>not</strong> for Apache servers.</p> </aside> <p> @@ -81,7 +81,7 @@ <p>If you want to check both a username and password with an ip address, use the <code>satisfy</code> directive.</p> <pre><code>location /api { #... - satify all ; + satisfy all ; allow 192.168.1.23:8080 ; deny 127.0.0.1 ; @@ -22,7 +22,7 @@ </p> <p> - You can receive these donations in BAT itself, or in another cryptocurreny of your choosing. + You can receive these donations in BAT itself, or in another cryptocurrency of your choosing. </p> <h3>Explanation of the BAT system</h3> <p> @@ -33,7 +33,7 @@ <h3>Why you might <em>not</em> want to enroll...</h3> <p> Unlike <a href="bitcoin.html">Bitcoin</a> and <a href="monero.html">Monero</a>, BAT is a token organized by a company, and as such, it has to comply with know-your-customer regulations. - What that means for you is that to get a payout in BAT, you must have an custodial cryptocurrency wallet with either Gemini or Uphold, the two services they are interfaced with. + What that means for you is that to get a payout in BAT, you must have a custodial cryptocurrency wallet with either Gemini or Uphold, the two services they are interfaced with. You can move your payouts elsewhere when you want, but those sites require real-world identification. </p> <p> diff --git a/bitcoin.html b/bitcoin.html index 5da6b50..81fc641 100644 --- a/bitcoin.html +++ b/bitcoin.html @@ -75,7 +75,7 @@ In fact, as you use these up, the wallet will automatically add more. </p> <p> - These addresses (which will all be generated with <code>bc1</code> at the beginning can be used by others to send you Bitcoins. + These addresses (which will all be generated with <code>bc1</code> at the beginning) can be used by others to send you Bitcoins. Someone can just copy-and-paste the address into their wallet to send you funds. </p> <img src="pix/bitcoin-03.png" alt="bitcoin addresses"> @@ -88,7 +88,7 @@ <h4>What is the QR code for?</h4> <p> In case you don't know, a QR code is a way of storing text information in a format that can be scanned by a phone. - If someone has a wallet program on a phone, then can easily scan the QR code on another screen to avoid having to copy your address over or even worse, write it manually. + If someone has a wallet program on a phone, they can easily scan the QR code on another screen to avoid having to copy your address over or even worse, write it manually. </p> <h3>Let's receive donations on our website.</h3> <p> diff --git a/certbot.html b/certbot.html index eaa3f4d..f632b98 100644 --- a/certbot.html +++ b/certbot.html @@ -41,7 +41,7 @@ <p>Just run:</p> - <pre><code>apt install python-certbot-nginx</code></pre> + <pre><code>apt install python3-certbot-nginx</code></pre> <p>And this will install <code>certbot</code> and its module for <code>nginx</code>.</p> @@ -76,8 +76,8 @@ ufw allow 443</code></pre> <img src=pix/certbot-01.png> <p> - It will take a moment to create the certiticate, but afterwards, you will be asked if you want to automatically redirect all connections to be encrypted. - Since this is preferrable, choose 2 to Redirect. + It will take a moment to create the certificate, but afterwards, you will be asked if you want to automatically redirect all connections to be encrypted. + Since this is preferable, choose 2 to Redirect. </p> <img src=pix/certbot-02.png> diff --git a/cgi.html b/cgi.html new file mode 100644 index 0000000..f54d547 --- /dev/null +++ b/cgi.html @@ -0,0 +1,268 @@ +<!DOCTYPE html> +<html lang=en> + <head> + <title>Server-Side Scripting with CGI</title> + <meta charset="utf-8"/> + <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> + <link rel='stylesheet' type='text/css' href='style.css'> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'> + </head> +<body> + <header><h1>Server-Side Scripting with CGI</h1></header> + <nav></nav> + <main> + <p> + The basic website tutorial here describes how to set up a static + website — one that just serves HTML files saved on your server, + and until you change something manually, the same content will be served + each time a given page is requested. This is perfectly enough for most + personal website needs. This is how blogs should be implemented, instead + of relying on bloatware like WordPress! + </p> + + <p> + But sometimes you genuinely <i>do</i> need something more. You need your + website to serve different contents depending on the time, on who the + requester is, on the contents of a database, or maybe process user input + from a form. + </p> + + <h2>CGI</h2> + <p> + CGI, or the Common Gateway Interface, is a specification to allow you, + the server owner, to program your web server using pretty much any + programming language you might know. The specification is almost as old + as the Internet itself and for a long time CGI scripting was the primary + method of creating dynamic websites. + </p> + + <p> + CGI is a very simple specification indeed. You write a script in your + favorite language, the script receives input about the request in + environment variables, and whatever you print to the standard output + will be the response. Most likely, though, you will want to use a + library for your language of choice that makes a lot of this + request/response handling simpler (e.g. parsing query parameters for + you, setting appropriate headers, etc.). + </p> + + <h3>Limitations of CGI</h3> + <p> + While in theory you could implement any sort of functionality with CGI + scripts, it's going to get difficult managing a lot of separate scripts + if they're supposed to be working in tandem to implement a dynamic + website. If you want to build a full out web application, you'd probably + be better off learning a web framework than gluing together Perl + scripts. + </p> + + <p> + That said, just as most of the web could be replaced with static + websites, much of the remaining non-static web could be replaced with a + few simple scripts, rather than bloated Ruby on Rails or Django + applications. + </p> + + <h2>Let's write a CGI script!</h2> + + <p> + We'll implement a simple example CGI script. I'll use Ruby for this + tutorial, but you'll be able to follow along even if you don't know + Ruby, just treat it as pseudocode then find a CGI library for your + language. + </p> + + <h3>The working example</h3> + + <p> + Our working example will be the Lazy Calculator. Yeah, you're probably + tired of seeing calculator examples in every programming tutorial, but + have you ever implemented one that takes the weekends off? + </p> + + <p> + Here's how it will work. When in a browser you submit a request to your + website like + </p> + + <pre><code>example.com/calculator.html?a=10&b=32</code></pre> + + <p> + you will receive a page with the result of the addition of 10 and 32: + 42. + </p> + + <p> + <i>Unless</i> you send your request on a weekend. Then the website will + respond with + </p> + + <pre><code>I don't get paid to work on weekends! Come back Monday.</code></pre> + + <p> + This example will show a few things that CGI scripts can do that you + wouldn't have been able to get using just file hosting in your + web server: + + <ul> + <li> getting inputs from the user; </li> + <li> + getting external information (here just the system time, but you + could imagine instead connecting to a database); + </li> + <li> using the above to create dynamic output. </li> + </ul> + + <h3>The code</h3> + + <p> + Here's an implementation of the lazy calculator as a Ruby CGI script: + </p> + + <pre><code>#!/bin/env ruby + +require 'cgi' +require 'date' + +cgi = CGI.new +today = Date::today + +a = cgi["a"].to_i +b = cgi["b"].to_i + +if today.saturday? || today.sunday? + cgi.out do + "I don't get paid to work on weekends! Come back Monday." + end +else + cgi.out do + (a + b).to_s + end +end</code></pre> + + <p> + Let's go through what's happening here. + </p> + + <h3>The shebang line</h3> + <p> + CGI works by pointing your web server to an executable program. A Ruby + or Python script by itself is not immediately executable by a computer. + But on Unix-like systems you can specify the program that will be able + to execute your file in its first line if it starts with <code>#!</code> + (known as the shebang; read more about it on + <a href="https://en.wikipedia.org/wiki/Shebang_(Unix)">Wikipedia</a>). + </p> + + <p> + So if you're going to be using a scripting language, you'll probably + need the appropriate shebang line at the top of your script. If you use + a compiled language, you'll just point your web server to the compiled + executable binary. + </p> + + <h3>Query parameters</h3> + <p> + The next interesting lines of code are where we set the variables + <code>a</code> and <code>b</code>. Here we are getting user inputs from + the request. + </p> + + <p> + In the example request we mentioned above + (<code>example.com/calculator.html?a=10&b=32</code>), the part + starting from the question mark, <code>?a=10&b=32</code>, is the + <i>query string</i>. This is how users can submit parameters with their + web requests. Usually these parameters are set by e.g. a form on your + website, but in our simple example we'll be just manually manipulating + the URL. + </p> + + <p> + The query string contains key-value pairs. The Ruby CGI library makes + them available in the <code>CGI</code> object it provides. We just need + to index it with the desired key, and we'll get the corresponding value. + </p> + + <h3>Wrapping it up</h3> + <p> + The remaining parts of the code should be pretty self-explanatory. We + get today's date, check if it's a Saturday or a Sunday, and depending on + that, we instruct the CGI library to output either the answer, or a + "come back later" message. + </p> + + <p> + The Ruby library by default returns an HTML response, so we really + should have wrapped our outputs in some <code>html</code>, + <code>body</code>, etc. tags. Alternatively, we could have specified + that the response is just plain text with + </p> + + <pre><code>cgi.out 'text/plain' do</code></pre> + + <p> + In general, your CGI library will probably have ways of specifying all + sorts of HTTP response headers, like status code, content type, etc. + </p> + + <h2>Making it work</h2> + <p> + We have a CGI script, now let's point our web server to it. + </p> + + <h3>Installing FastCGI</h3> + + <p> + If you're using Nginx, install <code>fcgiwrap</code>: + </p> + + <pre><code>apt install fcgiwrap</code></pre> + + <p> + This installs the necessary packages for Nginx to use FastCGI — a + layer between your web server and CGI script that allows for faster + handling of scripts than if the web server had to handle it all by + itself. + </p> + + <p> + Other web servers will probably have a similarly simple way of enabling + FastCGI, or you can look into other methods for launching CGI scripts. + </p> + + <h3>Nginx configuration</h3> + <p> + In the configuration file for your website, add something like the + following: + </p> + +<pre><code>location /calculator.html { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/local/bin/lazy-calculator.rb; + fastcgi_param QUERY_STRING $query_string; + fastcgi_pass unix:/run/fcgiwrap.socket; +}</code></pre> + + <p> + <code>fastcgi_param</code> directives specify various parameters for + FastCGI. <code>SCRIPT_FILENAME</code> should point to your executable. + For <code>QUERY_STRING</code>, we just copy Nginx's + <code>$query_string</code> variable. You might want to pass other + information to your CGI script as well, see for example + <a href="https://wiki.debian.org/nginx/FastCGI">the Debian wiki</a> for + a more detailed example, including pointing to an entire directory of + CGI scripts, rather than adding each one by hand to your web server + config. + </p> + + <h2>Contribution</h2> + <ul> + <li>Martin Chrzanowski -- <a + href="https://m-chrzan.xyz">website</a>, <a href="https://m-chrzan.xyz/crypto.html">donate</a></li> + </ul> + </main> + <footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer> +</body> +</html> @@ -19,13 +19,13 @@ <p> You can schedule anything! Some examples of what you might have done already include: <ul> - <li> <code> updatedb </code> to update your <code> locate </code> database </li> - <li> <code> certbot </code> to update renewing of your https certs </li> + <li><code>updatedb</code> to update your <code>locate</code> database</li> + <li><code>certbot</code> to update renewing of your https certs</li> </ul> Some tasks that you might <em>want</em> to schedule may include: <ul> - <li> Package updates - if you really just want to leave your server alone you can automated updating packages on your server </li> - <li> Backups - you may want to backup certain files every day and some every week, this is possible with cron </li> + <li>Package updates - if you really just want to leave your server alone you can automated updating packages on your server</li> + <li>Backups - you may want to backup certain files every day and some every week, this is possible with cron</li> </ul> <p> And many more, anything you can do can be turned into a cronjob. @@ -34,25 +34,25 @@ <h2>Basic Cronjobs</h2> <p> - This the preferred method for personal tasks and scripts, it's also the easiest to get started with. Run the command <code> crontab -e </code> to access your users crontab + This the preferred method for personal tasks and scripts; it's also the easiest to get started with. Run the command <code>crontab -e</code> to access your user's crontab </p> <p> - Once you have figured out the command you want to run you need to figure out how often you want to run it and when. I am going to schedule my system updates once a week on at 3:30 AM on a Monday. + Once you have figured out the command you want to run you need to figure out how often you want to run it and when. I am going to schedule my system updates once a week on at 3:30 AM on Mondays. </p> <p> We now have to convert this time (Every Monday at 3:30 AM) into a cron time. Cron uses a simple but effective way of scheduling when to run things. </p> <p> - Crontab expressions look like this <code> * * * * * command-to-run </code> + Crontab expressions look like this <code>* * * * * command-to-run</code> The five elements before the command tell when the command is supposed to be run automatically. <p> - So for our Monday at 3:30AM job we would do the following: + So for our Monday at 3:30 AM job we would do the following: <p> <pre><code> .---------------- minute (0 - 59) | .------------- hour (0 - 23) | | .---------- day of month (1 - 31) - | | | .------- month (1 - 12 + | | | .------- month (1 - 12) | | | | .---- day of week (0 - 6) | | | | | * * * * * @@ -67,7 +67,9 @@ <h3>More examples</h3> <p> - Let's add another job, our backup job (for the purposes of this our backup command is just called <code> backup</code>) We want to run <code> backup </code> Every evening at 11PM, once we work out the timings for this we can add the to the same file as the above by running <code> crontab -e </code> This would mean our full crontab would look like this: + Let's add another job, our backup job (for the purposes of this our backup command is just called <code>backup</code>). + We want to run <code>backup</code> every evening at 11PM. + Once we work out the timings for this we can add the to the same file as the above by running <code>crontab -e</code> This would mean our full crontab would look like this: <pre><code>0 23 * * * backup</code></pre> <h3>Consecutive times</h3> @@ -87,21 +89,18 @@ <p> We can also randomly specify non-consecutive arguments with a comma. Suppose you have a script you want to run at the midday of the 1st, 15th, and 20th day of every month. - You can specify that my putting <code>1,15,20</code> for the day of the month argument: + You can specify that by putting <code>1,15,20</code> for the day of the month argument: </p> <pre><code>0 12 1,15,20 * * /usr/bin/pay_bills_script</code></pre> <h3>"Every X minutes/days/months"</h3> - <p>We can also easily run a command very several minutes or months, without specifying the specific times: - </p> + <p>We can also easily run a command every several minutes or months, without specifying the specific times:</p> <pre><code>*/15 * * * * updatedb</code></pre> - <p> - This cronjob will run the <code>updatedb</code> command every 15 minutes. - </p> + <p>This cronjob will run the <code>updatedb</code> command every 15 minutes.</p> <h3>Beware of this Rookie Mistake Though...</h3> @@ -146,13 +145,14 @@ </p> <p> - Run the command <code> ls /etc/cron* </code> you should see a list of directories and there contents. The directories should be something like the below + Run the command <code>ls /etc/cron*</code> you should see a list of directories and there contents. The directories should be something like the below: + </p> <ul> - <li> /etc/cron.d <em> This is a crontab like the ones that you create with </em> <code> crontab -e </code> </li> - <li> /etc/cron.hourly </li> - <li> /etc/cron.daily </li> - <li> /etc/cron.weekly </li> - <li> /etc/cron.monthly </li> + <li>/etc/cron.d <em>This is a crontab like the ones that you create with</em> <code>crontab -e</code></li> + <li>/etc/cron.hourly</li> + <li>/etc/cron.daily</li> + <li>/etc/cron.weekly</li> + <li>/etc/cron.monthly</li> </ul> <p> @@ -76,7 +76,7 @@ <p> Now let's get our IPv6 address, which is a little more hidden for some reason. - IPv6 are important because we are running our of IPv4 addresses so it is highly important to allow connections via IPv6 as it will be standard in the future. + IPv6 is important because we are running out of IPv4 addresses, so it is highly important to allow connections via IPv6 as it will be standard in the future. Anyway, now back on Vultr, click on the server name. </p> @@ -87,7 +87,7 @@ <a href=pix/dns-vultr.png><img src="pix/dns-vultr.png" alt="Looking for the IPv6"></a> <p> - Now just click on <strong>IPv6</strong> submenu to reveal your IPv6 address. + Now just click on the <strong>IPv6</strong> submenu to reveal your IPv6 address. </p> <a href=pix/dns-ipv6.png><img src="pix/dns-ipv6.png" alt="The IPv6 address"></a> @@ -95,14 +95,15 @@ <p> That ugly looking sequence of numbers and letters with colons in between (<code>2001:19f0:5:ccc:5400:03ff:fe58:324a</code>) is my <strong>IPv6</strong> address. Yours will look something like it. - Now let's put it into Epik, this time, be sure to select to put in AAAA records as below: + Now let's put it into Epik. + This time, be sure to select to put in AAAA records as below: </p> <a href=pix/dns-ipv6-done.png><img src="pix/dns-ipv6-done.png" alt="IPv6 complete"></a> <p> Now just click "Save Changes." - It might take a minute for the DNS settings to propgate across the internet. + It might take a minute for the DNS settings to propagate across the internet. </p> <h2>Test it out!</h2> diff --git a/domain.html b/domain.html index 8d60310..283c37d 100644 --- a/domain.html +++ b/domain.html @@ -126,7 +126,7 @@ </li> <li>NearlyFreeSpeech – People have signed up for this minor registrar because of its name that's actually tongue-and-cheek. I will let <a href="https://web.archive.org/web/20210121022350/https://blog.nearlyfreespeech.net/2021/01/19/free-speech-in-2021">this post of theirs</a> speak for itself. Register a domain here only if you want to have it seized.</li> - <li>Google, Amazon – Maybe this is obvious, but if you are trying to escape the control of Google or Amazon, it is a very, self-defeating thing to register your domain with them.</li> + <li>Google, Amazon – Maybe this is obvious, but if you are trying to escape the control of Google or Amazon, it is a very self-defeating thing to register your domain with them.</li> </ul> <p> @@ -138,6 +138,6 @@ </p> </main> - <!-- <footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer> --> + <footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer> </body> </html> diff --git a/gemini.html b/gemini.html index 4963f2a..6bfbe75 100644 --- a/gemini.html +++ b/gemini.html @@ -38,7 +38,7 @@ <p>As the gemini user, we can create three different directories to simplify the process:</p> <pre><code>mkdir -p ~/gemini/{content,certificate,server}</code></pre> <h3>Content</h3> - <p>This will be the directory where you capsule files will be contained. Gemini uses text/gemini markup (in place of HTTP's equivalent HTML). It heavily borrows from Markdown. Similar to .html or .md, gemini uses .gmi as its extension.</p> + <p>This will be the directory where your capsule files will be contained. Gemini uses text/gemini markup (in place of HTTP's equivalent HTML). It heavily borrows from Markdown. Similar to .html or .md, gemini uses .gmi as its extension.</p> <p>To create one gemini file, go inside the <code>content</code> directory and create one <code>index.gmi</code> file.</p> <pre><code>nano gemini/content/index.gmi</code></pre> <p>We can add the content we want in our Gemini capsule here:</p> @@ -92,7 +92,7 @@ systemctl start agate</code></pre> <p>Enjoy your first gemini capsule.</p> <p> For information about how to write in "gemtext" the markup language in Gemini, see this site: <a href="https://gemini.circumlunar.space/docs/gemtext.gmi">https://gemini.circumlunar.space/docs/gemtext.gmi</a>. - As you might guess it also has an analogous gemini capsule here: gemini://gemini.circumlunar.space/docs/gemtext.gmi + As you might guess, it also has an analogous gemini capsule here: gemini://gemini.circumlunar.space/docs/gemtext.gmi </p> <hr> <p><em>Written by <a href="https://nihar.page">nihar.page</a></em></p> @@ -80,7 +80,7 @@ server { <h2>A few extras</h2> <h3>Automatically create a new repo on push</h3> - <p>This is an incredicly useful feature for me. Open up <code>/etc/gitea/app.ini</code> and add <code>DEFAULT_PUSH_CREATE_PRIVATE = true</code> to the <code>repository</code> section like so:</p> + <p>This is an incredibly useful feature for me. Open up <code>/etc/gitea/app.ini</code> and add <code>DEFAULT_PUSH_CREATE_PRIVATE = true</code> to the <code>repository</code> section like so:</p> <img src=pix/gitea-push-create.png> <br> <p>If you now add a remote to a repository like this</p> @@ -31,7 +31,7 @@ It is the "language" that all webpages are written in so that all browsers can read and display them properly. </p> <p> - A <dfn>markup language</dfn> <em>not</em> the same as a programming language: + A <dfn>markup language</dfn> is <em>not</em> the same as a programming language: Programming languages specify orders for a computer, while markup languages are ways of specifying the styling of text. Markup languages are necessary because computers run on mere text, not colors, sizes, headers and other styling things. </p> @@ -142,7 +142,7 @@ Heading tags are for your page's title and section headings in the document: <h4>A preview to CSS</h4> <p> -It is very imporant to use headings like this for your pages. +It is very important to use headings like this for your pages. Notice that on this website, headings come in different colors, text-alignment and sizes for emphasis. If we use these heading tags, when we clear CSS, we can easily style all <code><h2></code>, for example, @@ -47,9 +47,11 @@ <h3 id=other>Excellent Extras</h3> <ul class=ll> - <li><a href="maintenance.html">How to maintain a server.</a></li> + <li><a href="rsync.html">Rsync: Upload and Sync Files and Websites</a></li> + <li><a href="maintenance.html">How to Maintain a Server.</a></li> <li><a href="sshkeys.html">Use your SSH keys to prevent hacking.</a></li> <li><a href="cron.html">Schedule tasks with Crontabs/Cronjobs.</a></li> + <li><a href="cgi.html">Server side scripting with CGI</a></li> <li><a href="tor.html">Mirror your site on <img src="pix/tor.svg">Tor.</a></li> <li><a href="auth.html">Password-protecting Webpages (HTTP Authentication)</a></li> <li><a href="ufw.html">Using ufw as a firewall.</a></li> @@ -60,10 +62,12 @@ <h3 id=platform>"Build your own platform!"</h3> <ul class=ll> <li><a href="git.html">Host your own <img src="pix/git.svg"><code>git</code> repositories</a></li> + <li><a href="xmpp.html">Private and Encrypted Chat with <img src="pix/xmpp.svg" alt="xmpp logo">XMPP</a></li> <li><a href="pleroma.html">Pleroma, a federated Twitter-like Microblogging Site</a></li> <li><a href="nextcloud.html">Setting up a <img src="pix/nextcloud.svg">Nextcloud Instance (file hosting and more)</a></li> <li><a href="gitea.html">Setting up <img src="pix/gitea.svg">Gitea</a></li> <li><a href="irc.html">Creating your own chat server with <img src="pix/irc.svg">IRC</a></li> + <li><a href="rss-bridge.html">RSS Bridge: Create RSS Feeds for Mainstream Social Media</a></li> </ul> <h3 id=crypto>Accepting Cryptocurrency Tips</h3> @@ -88,9 +92,7 @@ <li>Full HTML tutorial</li> <li>Full CSS tutorial</li> <li>Setting up an Email server</li> - <li>Using rsync for websites and servers.</li> <li>RSS feeds</li> - <li>XMPP Prosody (federated chat)</li> <li>Matrix (federated chat)</li> <li>SearX (search engine)</li> </ul> @@ -106,13 +108,13 @@ </p> <ul> + <li><a href="https://btcpayserver.org/">BTCPay</a></li> <li>Email webclients</li> <li>Simple static site generators</li> <li>Calibre (library server)</li> - <li>Nitter</li> - <li>PeerTube (like YouTube)</li> - <li>XMPP ejabberd</li> - <li>Movim for XMPP</li> + <li><a href="https://joinpeertube.org/">PeerTube</a> (like YouTube)</li> + <li><a href="https://www.ejabberd.im/">XMPP ejabberd</a></li> + <li><a href="https://movim.eu/">Movim for XMPP</a></li> </ul> @@ -26,7 +26,7 @@ <p> An IRCd is short for "IRC daemon", which just means an IRC server. - The most easy IRCd to setup is <a href="https://ergo.chat/">Ergo</a>. + The most easy IRCd to set up is <a href="https://ergo.chat/">Ergo</a>. </p> <p> @@ -46,7 +46,7 @@ mkdir server</code></pre> <p> You can find the latest release of Ergo on its GitHub <a href="https://github.com/ergochat/ergo/releases/latest">latest release</a> page.<br> There are several platforms available, but you want to choose Linux, most likely <code>linux-x86_64</code>.<br> - Once you have selected the correct package, copy its URL and replace <code><i><release url></i></code> with the package URL (still as the <code>ergo</code> user): + Once you have selected the correct package, copy its URL and replace the release url with the package URL (still as the <code>ergo</code> user): </p> <pre><code>wget https://github.com/ergochat/ergo/releases/download/v2.7.0/ergo-2.7.0-linux-x86_64.tar.gz @@ -83,6 +83,11 @@ drwxr-xr-x 2 ergo ergo 12288 Jul 1 09:01 languages <pre><code>sudo -i -u ergo cd ~/server</code></pre> + <p>To start configuring, we need to copy some files:</p> + +<pre><code>cp default.yaml ircd.yaml +cp ergo.motd ircd.motd</code></pre> + <p> Next, generate certificate files for TLS: </p> @@ -95,15 +100,10 @@ cd ~/server</code></pre> go ahead and change them, as long as you know what you're doing. </p> - <p>To start configuring, we need to copy some files:</p> - -<pre><code>cp default.yaml ircd.yaml -cp ergo.motd ircd.motd</code></pre> - <p> - The next steps involve editing the newly copied <code>ircd.yaml</code> file. If you do not know how to edit text files from the comment line, + The next steps involve editing the newly copied <code>ircd.yaml</code> file. If you do not know how to edit text files from the command line, you can use <code>nano</code>, which is very simple, using arrow keys to navigate, <code>CTRL+O</code> to save, and <code>CTRL+X</code> to exit.<br> - Another option is <code>vim</code>, which is a much more powerful text editor, but has a learning curve. It is only recommended for this guide if you already know it.<br> + Another option is <code>vim</code>, which is a much more powerful text editor, but has a learning curve. It is only recommended for this guide if you already know how to use it.<br> Lastly, you can copy the <code>ircd.yaml</code> file to a text editor on your computer and edit it with a GUI text editor of your choice. If that is what you choose to do, you may want to just download the file from <a href="https://raw.githubusercontent.com/ergochat/ergo/master/default.yaml">Ergo's GitHub</a>, edit it on your computer, clear the <code>ircd.yaml</code> file on the server, and then paste the contents from your computer into the blank file.<br> @@ -210,9 +210,9 @@ ip-cloaking: <h3 id="configuring-hexchat-password">Password enforcement adjustments for HexChat (and possibly other clients)</h3> <p> Ergo offers account registration to allow users to do things like use history and bouncer features, register channels, etc.<br> - In clients such as HexChat, server password may conflict with account passwords, so the following setting should be enable if you wish to use accounts with clients such as HexChat.<br> + In clients such as HexChat, server passwords may conflict with account passwords, so the following setting should be enabled if you wish to use accounts with clients such as HexChat.<br> Note that this could under some circumstances be considered a security hazard, as a user with an account does not need to know the server password to connect, - although that user would have needed to register an account before the server had a password, and then a password would need to have been set after the fact, so this can be considered a very small concern if your setup always has had a password.<br> + although that user would have needed to register an account before the server had a password, and then a password would need to have been set after the fact, so this can be considered a very small concern if your setup has always had a password.<br> Also keep in mind that this setting has no effect if your network does not even have a password at all. </p> diff --git a/matrix.html b/matrix.html new file mode 100644 index 0000000..47898f8 --- /dev/null +++ b/matrix.html @@ -0,0 +1,87 @@ +<!DOCTYPE html> +<html lang=en> + <head> + <title>Matrix Synapse Server – LandChad.net</title> + <meta charset="utf-8"/> + <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> + <link rel='stylesheet' type='text/css' href='style.css'> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'> + </head> +<body> + <header><h1>Matrix Synapse Server</h1></header> + <nav></nav> + <main> + <p>Matrix is easy-to-use, decentralized and encrypted private chat software. + Matrix is federated, meaning that with a Matrix account on any server, including your own, you can talk to any other Matrix account on the internet, similar to email. + Matrix also allows fully end-to-end encrypted group chats. + </p> + + <p><strong>Synapse</strong> is the name of the default Matrix server. It is written in Python.</p> + + <h2>Installation</h2> + + <p>Synapse is not in the Debian package repositories by default, but we can easily add Matrix's repository including it:</p> + +<pre><code>apt install -y lsb-release wget apt-transport-https +wget -O /usr/share/keyrings/matrix-org-archive-keyring.gpg https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/matrix-org.list</code></pre> + <p>After we update our packages lists, we will be able to install Synapse with <code>apt</code>.</p> + +<pre><code>apt update +apt install matrix-synapse-py3</code></pre> + +<p>When prompted, give your main domain name (not a subdomain). This will be the domain appended to your Matrix address, e.g. <code>@chad:landchad.net</code>.</p> + + <h2>Nginx configuration</h2> + + <p>Create an Nginx configuration file for Matrix, say <code>/etc/nginx/sites-available/matrix</code> and add the content below: + </p> + + <pre><code>server { + server_name matrix.<strong>example.org</strong> ; + listen 80; + listen [::]:80; + location / { + proxy_pass http://localhost:8008; + } + location ~* ^(\/_matrix|\/_synapse\/client) { + proxy_pass http://localhost:8008; + proxy_set_header X-Forwarded-For $remote_addr; + client_max_body_size <strong>50M</strong> ; + } + location /.well-known/matrix/client { + return 200 '{"m.homeserver": {"base_url": "https://matrix.<strong>example.org</strong>"}}'; + default_type application/json; + add_header Access-Control-Allow-Origin *; + } +}</code></pre> + + <aside> + <p>Note the <code>client_max_body_size</code> variable. By default, Nginx caps the size of files it can transfer. We increase that to 50M if needed by Matrix. (Note however that both Matrix and Nginx have seperate settings for this and to raise it to something much larger, you will have to increase the value in both congfiguration files.) + </p> + </aside> + + <p>Now let's enable the Nginx Matrix site and reload Nginx to make it active.</p> + + <pre><code>ln -s /etc/nginx/sites-available/matrix /etc/nginx/sites-enabled +systemctl reload nginx</code></pre> + + <h3>Encryption</h3> + + <p>Obviously, we need to encrypt our <code>matrix</code> subdomain as well. Let's do that with certbot:</p> + +<pre><code>certbot --nginx -d matrix.<strong>example.org</strong></code></pre> + + <h2>Configuration</h2> + + <p> + The configuration file for Matrix is in <code>/etc/matrix-synapse/homeserver.yaml</code>. + It is well documented and commented, so you can read about the settings, but let's change the essential ones here. + </p> + + <p><strong>This article isn't finished. Deal with basic settings and registering accounts.</strong></p> + </main> + <footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer> +</body> +</html> diff --git a/monero.html b/monero.html index b44164f..498a28e 100644 --- a/monero.html +++ b/monero.html @@ -30,7 +30,7 @@ If you are a Windows user, note that you will <em>probably</em> get some kind of warning that you are installing something malicious. This is because many malicious pieces of software include crypto miners in them. This wallet, obviously, does include one as well, because it has the ability to mine if you want. - You can disregard these messages and as that official site mentions, you can follow their directions to check the integrity of the download with SHA265. + You can disregard these messages and as that official site mentions, you can follow their directions to check the integrity of the download with SHA256. </p> </aside> diff --git a/nextcloud.html b/nextcloud.html index 259c361..2ba4472 100644 --- a/nextcloud.html +++ b/nextcloud.html @@ -42,7 +42,12 @@ EXIT;</code></pre> <p>Check for the <code>www-data</code> user by running <code>id -u www-data</code>. If a number is output from that command, then the www-data user exists. If not. add the user simply by running <code>useradd www-data</code></p> <p>Next, we need to ensure that we have SSL certificates generated for your website. If you have not already done this, refer to <a href="certbot.html">this guide</a>. Although having SSL for your site is not required, it is highly recommended that you have it or you will risk attackers being able to steal passwords and data.</p> <p>In <code>/etc/nginx/sites-available/</code> we need to make a new configuration for Nextcloud (example: <code>/etc/nginx/sites-available/nextcloud</code>). Create it and open it, modify, and add the following lines:</p> - <pre><code>server { + <pre><code>upstream php-handler { + server unix:/var/run/php/php7.4-fpm.sock; + server 127.0.0.1:9000; +} + +server { listen 80; listen [::]:80; server_name <strong>yourwebsite.com</strong>; @@ -90,8 +95,6 @@ server { gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; - pagespeed off; - add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Download-Options "noopen" always; @@ -140,7 +143,7 @@ server { location ~ \.woff2?$ { try_files $uri /nextcloud/index.php$request_uri; - expires 7d; + expires 7d; access_log off; } @@ -155,7 +158,7 @@ server { }</code></pre> <p>Enable the site by running this command:</p> <pre><code>ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/</code></pre> - <p>Next, we need to download the latest release tarball of Nextcloud. Go to <a>https://nextcloud.com/install/#instructions-server</a> and copy the URL of the the .tar.bz2 tarball from the More Downloads dropdown menu then go to your server's shell prompt and download the tarball with wget. Here is an example:</p> + <p>Next, we need to download the latest release tarball of Nextcloud. Go to <a>https://nextcloud.com/install/#instructions-server</a> and copy the URL of the .tar.bz2 tarball from the More Downloads dropdown menu then go to your server's shell prompt and download the tarball with wget. Here is an example:</p> <pre><code>wget https://download.nextcloud.com/server/releases/nextcloud-21.0.2.tar.bz2</code></pre> <p>Now we need to extract the Nextcloud tarball. Run the following command:</p> <pre><code>tar -xjf nextcloud*.tar.bz2 -C /var/www</code></pre> @@ -16,7 +16,7 @@ As I said in previous articles, the instructions I will give will be for <strong>Debian 10</strong>. In this article, other distributions might work a little differently.</p> - <h2>Logging in the the server</h2> + <h2>Logging in to the server</h2> <p> We first want to log into our VPS to get a command prompt where we can set up the web server. @@ -33,7 +33,7 @@ Now pull up a terminal and type: </p> - <pre><code>ssh root@<strong>yourdomain.com</strong></code></pre> + <pre><code>ssh root@<strong>example.org</strong></code></pre> <p> This command will attempt to log into your server. @@ -44,7 +44,7 @@ <p> If you get an error here, you might not have done your <a href="dns.html">DNS settings</a> right. Double check those. - Note you can also replace the <code>yourdomain.com</code> with your IP address, but you'll want to fix your DNS settings soon. + Note you can also replace the <code>example.org</code> with your IP address, but you'll want to fix your DNS settings soon. </p> </aside> @@ -190,7 +190,7 @@ Now we can just <code>reload</code> or <code>restart</code> to make <code>nginx< <p> Vultr and some other VPS automatically install and enable <code>ufw</code>, a firewall program. -This will block bacsically everything by default, so we have to change that. +This will block basically everything by default, so we have to change that. If you don't have <code>ufw</code> installed, you can skip this section. </p> diff --git a/openalias.html b/openalias.html index 60a9953..dd11629 100644 --- a/openalias.html +++ b/openalias.html @@ -32,7 +32,7 @@ <p> It would be nice if we could just input someone's email address or maybe a website and send Bitcoin or Monero to that instead. - So instead of that long jumble, it would be eaiser to just type in someone's website or email and sending them money that way. + So instead of that long jumble, it would be easier to just type in someone's website or email and sending them money that way. </p> <h2>The Solution</h2> diff --git a/rss-bridge.html b/rss-bridge.html new file mode 100644 index 0000000..59f51c0 --- /dev/null +++ b/rss-bridge.html @@ -0,0 +1,98 @@ +<!DOCTYPE html> +<html lang=en> + <head> + <title>Setting up RSS Bridge – LandChad.net</title> + <meta charset="utf-8"/> + <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> + <link rel='stylesheet' type='text/css' href='style.css'> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'> + </head> +<body> + <header><h1>Setting up RSS Bridge</h1></header> + <nav></nav> + <main> + + <p>RSS Bridge is a useful utility you can use to help you avoid the big tech sites, like Facebook and Twitter, which instead of the feed you usually would see, will be a based and minimalist RSS feed. </p> + + + <p>You'll need a server or VPS. Nearly any Operating system is supported but for this tutorial I'm gonna presume you're using a Debian-based OS. You'll also need a domain name pointing to your server's IP address <a href="https://landchad.net/dns.html">which is explained in this tutorial.</a> + </p> + + + +<h2>Installation</h2> + +<h3>Setting Up and Configuring</h3> + +<p>First things first you'll need to make sure that you've hardened you SSH so that password authentication is disabled and you'll also want to setup Fail2Ban. +There's a great tutorial on how to do this <a href="https://landchad.net/sshkeys.html">which can be read here.</a> +</p> + +<p> +Next we'll install the required packages: +</p> + +<pre><code>apt install -y curl unzip nginx certbot php-fpm php-mysql php-cli php7.3-mbstring php7.3-curl php7.3-xml php7.3-sqlite3 php7.3-json</code></pre> + +<p>We now have to create the website configuration file. Create/open the a file below:</p> +<pre><code>nano /etc/nginx/sites-available/rss-bridge</code></pre> +<p>And add the following content:</p> + +<pre><code>server { + root /var/www/rss-bridge; + index index.php index.html index.htm index.nginx-debian.html; + server_name rss-bridge.<strong>example.org</strong>; + + location / { + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; + } + + location ~ /\.ht { + deny all; + } +} +</code></pre> + +<p>After you have saved the file, you need to create a symlink so the server actually will read the file.</p> +<pre><code>ln -s /etc/nginx/sites-available/rss-bridge /etc/nginx/sites-enabled/rss-bridge</code></pre> + +<p>Then we have to create the folder where the service will reside in.</p> +<pre><code>mkdir -p /var/www/rss-bridge +cd /var/www/rss-bridge +</code></pre> + +<p>Lets download the latest version of RSS-Bridge in the directory.</p> +<p>The newest version can be found <a href="https://github.com/RSS-Bridge/rss-bridge/releases">here</a>, at the time of writing that is "RSS-Bridge 2021-04-25."</p> + <pre><code>wget https://github.com/RSS-Bridge/rss-bridge/archive/refs/tags/<strong>2021-04-25.zip</strong></code></pre> +<p>Unzip the file:</p> +<pre><code>unzip <strong>2021-04-25.zip</strong></code></pre> +<p>This will create a directory called rss-bridge-version-number, we now want to move all the file contents of the newly created directory to the one we are in</p> +<pre><code>mv <strong>rss-bridge-2021-04-25</strong>/* . +rm -rf <strong>rss-bridge-2021-04-25 2021-04-25.zip</strong> +</code></pre> + +<p>Now all we need to do is grant read/write permissions and reload the web server.</p> + +<pre><code>chown -R www-data:www-data /var/www/rss-bridge +systemctl reload nginx +</code></pre> + +<p>That's it, you should now have a working rss-bridge installed. But you should definately get an SSL certifcate installed <a href="https://landchad.net/certbot.html">which is done briefly here</a>.</p> + + +<ul> + <li><a href="https://handskemager.xyz">handskemager.xyz</a></li> + <li>Bitcoin: <code class=crypto>bc1qhfjgwjzksf2auqjefwpvq20wvyugq3lhqgkxvu</code></li> + <li>Monero: <code class=crypto>88cPx6Gzv5RWRRJLstUt6hACF1BRKPp1RMka1ukyu2iuHT7iqzkNfMogYq3YdDAC8AAYRqmqQMkCgBXiwdD5Dvqw3LsPGLU</code></li> +</ul> + + </main> + <footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer> +</body> +</html> @@ -16,6 +16,503 @@ <!-- LB --> <item> +<title>Server-Side Scripting with CGI</title> +<guid>https://landchad.net/cgi.html</guid> +<link>https://landchad.net/cgi.html</link> +<pubDate>Sun, 25 Jul 2021 14:29:44 -0400</pubDate> +<description><![CDATA[ + <header><h1>Server-Side Scripting with CGI</h1></header> + + <main> + <p> + The basic website tutorial here describes how to set up a static + website — one that just serves HTML files saved on your server, + and until you change something manually, the same content will be served + each time a given page is requested. This is perfectly enough for most + personal website needs. This is how blogs should be implemented, instead + of relying on bloatware like WordPress! + </p> + <p> + But sometimes you genuinely <i>do</i> need something more. You need your + website to serve different contents depending on the time, on who the + requester is, on the contents of a database, or maybe process user input + from a form. + </p> + <h2>CGI</h2> + <p> + CGI, or the Common Gateway Interface, is a specification to allow you, + the server owner, to program your web server using pretty much any + programming language you might know. The specification is almost as old + as the Internet itself and for a long time CGI scripting was the primary + method of creating dynamic websites. + </p> + <p> + CGI is a very simple specification indeed. You write a script in your + favorite language, the script receives input about the request in + environment variables, and whatever you print to the standard output + will be the response. Most likely, though, you will want to use a + library for your language of choice that makes a lot of this + request/response handling simpler (e.g. parsing query parameters for + you, setting appropriate headers, etc.). + </p> + <h3>Limitations of CGI</h3> + <p> + While in theory you could implement any sort of functionality with CGI + scripts, it's going to get difficult managing a lot of separate scripts + if they're supposed to be working in tandem to implement a dynamic + website. If you want to build a full out web application, you'd probably + be better off learning a web framework than gluing together Perl + scripts. + </p> + <p> + That said, just as most of the web could be replaced with static + websites, much of the remaining non-static web could be replaced with a + few simple scripts, rather than bloated Ruby on Rails or Django + applications. + </p> + <h2>Let's write a CGI script!</h2> + <p> + We'll implement a simple example CGI script. I'll use Ruby for this + tutorial, but you'll be able to follow along even if you don't know + Ruby, just treat it as pseudocode then find a CGI library for your + language. + </p> + <h3>The working example</h3> + <p> + Our working example will be the Lazy Calculator. Yeah, you're probably + tired of seeing calculator examples in every programming tutorial, but + have you ever implemented one that takes the weekends off? + </p> + <p> + Here's how it will work. When in a browser you submit a request to your + website like + </p> + <pre><code>example.com/calculator.html?a=10&b=32</code></pre> + <p> + you will receive a page with the result of the addition of 10 and 32: + 42. + </p> + <p> + <i>Unless</i> you send your request on a weekend. Then the website will + respond with + </p> + <pre><code>I don't get paid to work on weekends! Come back Monday.</code></pre> + <p> + This example will show a few things that CGI scripts can do that you + wouldn't have been able to get using just file hosting in your + web server: + <ul> + <li> getting inputs from the user; </li> + <li> + getting external information (here just the system time, but you + could imagine instead connecting to a database); + </li> + <li> using the above to create dynamic output. </li> + </ul> + <h3>The code</h3> + <p> + Here's an implementation of the lazy calculator as a Ruby CGI script: + </p> + <pre><code>#!/bin/env ruby +require 'cgi' +require 'date' +cgi = CGI.new +today = Date::today +a = cgi["a"].to_i +b = cgi["b"].to_i +if today.saturday? || today.sunday? + cgi.out do + "I don't get paid to work on weekends! Come back Monday." + end +else + cgi.out do + (a + b).to_s + end +end</code></pre> + <p> + Let's go through what's happening here. + </p> + <h3>The shebang line</h3> + <p> + CGI works by pointing your web server to an executable program. A Ruby + or Python script by itself is not immediately executable by a computer. + But on Unix-like systems you can specify the program that will be able + to execute your file in its first line if it starts with <code>#!</code> + (known as the shebang; read more about it on + <a href="https://en.wikipedia.org/wiki/Shebang_(Unix)">Wikipedia</a>). + </p> + <p> + So if you're going to be using a scripting language, you'll probably + need the appropriate shebang line at the top of your script. If you use + a compiled language, you'll just point your web server to the compiled + executable binary. + </p> + <h3>Query parameters</h3> + <p> + The next interesting lines of code are where we set the variables + <code>a</code> and <code>b</code>. Here we are getting user inputs from + the request. + </p> + <p> + In the example request we mentioned above + (<code>example.com/calculator.html?a=10&b=32</code>), the part + starting from the question mark, <code>?a=10&b=32</code>, is the + <i>query string</i>. This is how users can submit parameters with their + web requests. Usually these parameters are set by e.g. a form on your + website, but in our simple example we'll be just manually manipulating + the URL. + </p> + <p> + The query string contains key-value pairs. The Ruby CGI library makes + them available in the <code>CGI</code> object it provides. We just need + to index it with the desired key, and we'll get the corresponding value. + </p> + <h3>Wrapping it up</h3> + <p> + The remaining parts of the code should be pretty self-explanatory. We + get today's date, check if it's a Saturday or a Sunday, and depending on + that, we instruct the CGI library to output either the answer, or a + "come back later" message. + </p> + <p> + The Ruby library by default returns an HTML response, so we really + should have wrapped our outputs in some <code>html</code>, + <code>body</code>, etc. tags. Alternatively, we could have specified + that the response is just plain text with + </p> + <pre><code>cgi.out 'text/plain' do</code></pre> + <p> + In general, your CGI library will probably have ways of specifying all + sorts of HTTP response headers, like status code, content type, etc. + </p> + <h2>Making it work</h2> + <p> + We have a CGI script, now let's point our web server to it. + </p> + <h3>Installing FastCGI</h3> + <p> + If you're using Nginx, install <code>fcgiwrap</code>: + </p> + <pre><code>apt install fcgiwrap</code></pre> + <p> + This installs the necessary packages for Nginx to use FastCGI — a + layer between your web server and CGI script that allows for faster + handling of scripts than if the web server had to handle it all by + itself. + </p> + <p> + Other web servers will probably have a similarly simple way of enabling + FastCGI, or you can look into other methods for launching CGI scripts. + </p> + <h3>Nginx configuration</h3> + <p> + In the configuration file for your website, add something like the + following: + </p> +<pre><code>location /calculator.html { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/local/bin/lazy-calculator.rb; + fastcgi_param QUERY_STRING $query_string; + fastcgi_pass unix:/run/fcgiwrap.socket; +}</code></pre> + <p> + <code>fastcgi_param</code> directives specify various parameters for + FastCGI. <code>SCRIPT_FILENAME</code> should point to your executable. + For <code>QUERY_STRING</code>, we just copy Nginx's + <code>$query_string</code> variable. You might want to pass other + information to your CGI script as well, see for example + <a href="https://wiki.debian.org/nginx/FastCGI">the Debian wiki</a> for + a more detailed example, including pointing to an entire directory of + CGI scripts, rather than adding each one by hand to your web server + config. + </p> + <h2>Contribution</h2> + <ul> + <li>Martin Chrzanowski -- <a + href="https://m-chrzan.xyz">website</a>, <a href="https://m-chrzan.xyz/crypto.html">donate</a></li> + </ul> + </main> + +]]></description> +</item> + + +<item> +<title>XMPP Server (Prosody)</title> +<guid>https://landchad.net/xmpp.html</guid> +<link>https://landchad.net/xmpp.html</link> +<pubDate>Wed, 21 Jul 2021 22:58:21 -0400</pubDate> +<description><![CDATA[ + <header><h1>XMPP Server (Prosody)</h1></header> + + <main> + <img class=titleimg src="pix/xmpp.svg" alt="XMPP Logo and Icon"> + <p>XMPP is a fantastically simple protocol that's usually used as a messenger. + It's highly extensible, + better than IRC, + lighter and more decentralized and Matrix + and Telegram and normie social media can't hold a candle to it. + </p> + <p> + XMPP is so decentralized and extensible that there are many <em>different</em> XMPP servers. + Here, let's set up an <a href="https://prosody.im/">Prosody</a> XMPP server. + </p> + <h2>Installation</h2> + <p> + Prosody is in the Debian repositories, so we can easily install it on our server with the following command: + </p> + <pre><code>apt install prosody</code></pre> +<h2>Configuration</h2> +<p> +The Prosody configuration file is in <code>/etc/prosody/prosody.cfg.lua</code>. +To set it all up, we will be changing several things. +</p> +<h3>Setting Admins</h3> +<p> +Let's go ahead and set who our admin(s) will be. +Find the line that says <code>admins = { }</code> and to this we can specify one or more server admins. +</p> +<pre><code># To add one admin: +admins = { "chad@example.org" } +# We can add more than one by separating them by commas. (This file is written in Lua.) +admins = { "chad@example.org", "chadmin@example.org" }</code></pre> +<p> +Note that we have not created these accounts yet, we will do this <a href=#user>below</a>. +</p> +<h3>Set the Server URL</h3> +<p> +Find the line <code>VirtualHost "localhost"</code> and replace <code>localhost</code> with your domain. +In our case, we will have <code>VirtualHost "example.org"</code> +</p> +<h3>Multi-User Chats</h3> +<p> +Most people will probably want the ability to have chats with more than two users. +This is easily enough to enable. +In the config file, add the following: +</p> +<pre><code>Component "<strong>chat.example.org</strong>" "muc" + modules_enabled = { "muc_mam" } + restrict_room_creation = "admin"</code></pre> +<p> +On the first line, you must have a separate subdomain for your multi-user chats. +I use the <code>chat.</code> subdomain, but some use <code>muc.</code>. +Anything if possible. +</p> +<p> +The second line is important because it prevents non-admins from creating and squatting rooms on your server. +The only situation where you might not want that is if you indend to open a general public chat system for people you don't know. +</p> +<aside> +<p> +Read more about the <code>muc</code> plugin on the Prosody documentation page <a href="https://prosody.im/doc/modules/mod_muc">here</a>. +</p> +</aside> +<h3>End-to-end Encryption</h3> +<p> +Importantly, we'll want end-to-end encryption enabled for user privacy. +</p> +<p> +Find the array beginning with <code>modules_enabled</code>. +This includes a list of modules to be used. +Add +<code>"omemo_all_access";</code> to that list. +Additionally, be sure to change the module <code>pep</code> to <code>pep_simple</code> or this will cause a conflict.</p> +<p> +This module is not installed by default, +but you can easily download it by running the following command on the command prompt +to download and install the module to the correct directory. +</p> +<pre class=wide><code>curl -sL https://hg.prosody.im/prosody-modules/raw-file/785389a2d2b3/mod_omemo_all_access/mod_omemo_all_access.lua > /usr/lib/prosody/modules/mod_omemo_all_access.lua</code></pre> +<h3>Other things to check</h3> +<p>Check the config file for other settings you might want to change. +For example, if you want to run a general public XMPP server, you can allow anyone to create an account by changing <code>allow_registration</code> to <code>true</code>. +</p> +<h2>Certificates</h2> +<p> +Obviously, we want to have client-to-server and server-to-server encryption. +Nowadays, use can use Certbot to generate certificates and use a convenient command below <code>prosodyctl</code> to import them. +</p> +<p> +<strong>If you have multi-user chat enabled, be sure to get a certificate for that subdomain as well.</strong> +Include the <code>--nginx</code> option assuming you have an Nginx server running. +</p> +<pre><code>certbot -d <strong>chat.example.org</strong> --nginx</code></pre> +<p> +Once you have the certificates for encryption, run the following to import them into Prosody. +</p> +<pre><code>prosodyctl --root cert import /etc/letsencrypt/live/</code></pre> +<p> +Note that you might get an error that a certificate has not been found if your <code>muc</code> subdomain and your main domain share a certificate. +It should still work, this is just notifying you that no specific +</p> +<p> +For user privacy, we will definitely want to install and enable encryption with OMEMO. +</p> +<h2 id=user>Creating users/admins manually</h2> +<p> +Let's manually create the admin user we prepared for above. +Note that you can indeed do this in your XMPP client if you have not disabled registration, but this is how it is done on the command line: +</p> +<pre><code>prosodyctl adduser <strong>chad@example.org</strong></code></pre> +<p>This will prompt you to create a password as well.</p> +<h2>Make changes active</h2> +<p> +With any system service, use <code>systemctl reload</code> or <code>systemctl restart</code> to make the new settings active: +</p> +<pre><code>systemctl restart prosody</code></pre> +<h2>Using your Server!</h2> +<p> +Once your server is set up, you just need an XMPP client to use your new and secure chat system. +</p> +<ul> + <li>GNU/Linux: <a href="https://dino.im/">Dino</a> or <a href="https://gajim.org/">Gajim</a></li> + <li>Windows: <a href="https://gajim.org/">Gajim</a> also runs on Windows.</li> + <li>Android: <a href="https://conversations.im/">Conversations.im</a></li> + <li>Mac/iOS: <a href="https://monal.im/">Monal IM</a> or <a href="https://siskin.im/">Siskin</a> for iOS alone</li> + <li>command-line (GNU/Linux, MacOS, Windows): <a href="https://profanity-im.github.io/">Profanity</a></li> + <li><a href="https://xmpp.org/software/clients.html">See a more complete list kept by XMPP</a></li> +</ul> +<p> +Install whichever of these clients you want on your computer or phone and you can log into your new XMPP server with the account you made. +Note that if you enabled public registration, anyone can create an account on your server through one of these clients. +</p> +<h3>Account addresses</h3> +<p> +XMPP account addressed look just like email addresses: <code><strong>username@example.org</strong></code>. +You can message any account on any XMPP server on the internet with that format. +</p> +<h3>Note on MUCs (multi-user chats)</h3> +<p> +Remember that MUCs are kept on a separate subdomain that we created and should've gotten a certificate for above, for example, <code><strong>muc.example.org</strong></code>. +Chatrooms are created and referred to in the following format: <code><strong>#chatroomname@muc.example.org</strong></code>. +</p> + </main> + +]]></description> +</item> + + +<item> +<title>Setting up RSS Bridge</title> +<guid>https://landchad.net/rss-bridge.html</guid> +<link>https://landchad.net/rss-bridge.html</link> +<pubDate>Mon, 05 Jul 2021 18:11:15 -0400</pubDate> +<description><![CDATA[ + <header><h1>Setting up RSS Bridge</h1></header> + + <main> + <p>RSS Bridge is a useful utility you can use to help you avoid the big tech sites, like Facebook and Twitter, which instead of the feed you usually would see, will be a based and minimalist RSS feed. </p> + <p>You'll need a server or VPS. Nearly any Operating system is supported but for this tutorial I'm gonna presume you're using a Debian-based OS. You'll also need a domain name pointing to your server's IP address <a href="https://landchad.net/dns.html">which is explained in this tutorial.</a> + </p> +<h2>Installation</h2> +<h3>Setting Up and Configuring</h3> +<p>First things first you'll need to make sure that you've hardened you SSH so that password authentication is disabled and you'll also want to setup Fail2Ban. +There's a great tutorial on how to do this <a href="https://landchad.net/sshkeys.html">which can be read here.</a> +</p> +<p> +Next we'll install the required packages: +</p> +<pre><code>apt install -y curl unzip nginx certbot php-fpm php-mysql php-cli php7.3-mbstring php7.3-curl php7.3-xml php7.3-sqlite3 php7.3-json</code></pre> +<p>We now have to create the website configuration file. Create/open the a file below:</p> +<pre><code>nano /etc/nginx/sites-available/rss-bridge</code></pre> +<p>And add the following content:</p> +<pre><code>server { + root /var/www/rss-bridge; + index index.php index.html index.htm index.nginx-debian.html; + server_name rss-bridge.<strong>example.org</strong>; + location / { + try_files $uri $uri/ =404; + } + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; + } + location ~ /\.ht { + deny all; + } +} +</code></pre> +<p>After you have saved the file, you need to create a symlink so the server actually will read the file.</p> +<pre><code>ln -s /etc/nginx/sites-available/rss-bridge /etc/nginx/sites-enabled/rss-bridge</code></pre> +<p>Then we have to create the folder where the service will reside in.</p> +<pre><code>mkdir -p /var/www/rss-bridge +cd /var/www/rss-bridge +</code></pre> +<p>Lets download the latest version of RSS-Bridge in the directory.</p> +<p>The newest version can be found <a href="https://github.com/RSS-Bridge/rss-bridge/releases">here</a>, at the time of writing that is "RSS-Bridge 2021-04-25."</p> + <pre><code>wget https://github.com/RSS-Bridge/rss-bridge/archive/refs/tags/<strong>2021-04-25.zip</strong></code></pre> +<p>Unzip the file:</p> +<pre><code>unzip <strong>2021-04-25.zip</strong></code></pre> +<p>This will create a directory called rss-bridge-version-number, we now want to move all the file contents of the newly created directory to the one we are in</p> +<pre><code>mv <strong>rss-bridge-2021-04-25</strong>/* . +rm -rf <strong>rss-bridge-2021-04-25 2021-04-25.zip</strong> +</code></pre> +<p>Now all we need to do is grant read/write permissions and reload the web server.</p> +<pre><code>chown -R www-data:www-data /var/www/rss-bridge +systemctl reload nginx +</code></pre> +<p>That's it, you should now have a working rss-bridge installed. But you should definately get an SSL certifcate installed <a href="https://landchad.net/certbot.html">which is done briefly here</a>.</p> +<ul> + <li><a href="https://handskemager.xyz">handskemager.xyz</a></li> + <li>Bitcoin: <code class=crypto>bc1qhfjgwjzksf2auqjefwpvq20wvyugq3lhqgkxvu</code></li> + <li>Monero: <code class=crypto>88cPx6Gzv5RWRRJLstUt6hACF1BRKPp1RMka1ukyu2iuHT7iqzkNfMogYq3YdDAC8AAYRqmqQMkCgBXiwdD5Dvqw3LsPGLU</code></li> +</ul> + </main> + +]]></description> +</item> + + +<item> +<title>Rsync: Upload and Sync Files and Websites</title> +<guid>https://landchad.net/rsync.html</guid> +<link>https://landchad.net/rsync.html</link> +<pubDate>Sat, 03 Jul 2021 08:58:29 -0400</pubDate> +<description><![CDATA[ +<header><h1>Rsync: Upload and Sync Files and Websites</h1></header> +<main> + <p>rsync is a simple way to copy files and folders between your local computer and server.</p> + <p>It not only makes file-transfer easy, but it allows you to build and maintain your website offline, then easily upload it to the proper directory on your server so you don't need to constantly be logged into your server to modify your site.</p> +<h2 id="installing-rsync">Installing rsync</h2> +<p>Run the following on your server <em>and</em> on your local machine.</p> +<pre><code>apt install rsync</code></pre> +<h2 id="uploading-files-with-rsync">Uploading files with rsync</h2> +<p>From your local machine you can upload files to your server like this:</p> +<pre><code>rsync -ruvzP <strong>/path/to/file</strong> <strong>root@example.org:/path/on/the/server</strong></code></pre> +<p>You will be prompted for the root password and then uploading will commence.</p> +<p>If you omit <strong>root@</strong>, rsync will not attempt to log in as root, but whatever your local username is.</p> +<h3>Options to rsync</h3> +<p>In this command, we give several options to rsync:</p> +<ul> + <li><code>-r</code> – run recurssively (include directories)</li> + <li><code>-u</code> – update files (do not reupload files that are not changed since last upload)</li> + <li><code>-v</code> – visual, show files uploaded</li> + <li><code>-z</code> – compress files for upload</li> + <li><code>-P</code> – if uploading a large file and upload breaks, pick up where we left off rather than reuploading the entire file</li> +</ul> +<p>Avoid using the commonly used <code>-a</code> option when uploading. It changes can transfer your local machine's user and group permissions to your server, which might cause breakage.</p> +<h3>Scriptability</h3> +<p>It's a good idea to build your website offline, then make an rsync script or bash alias like the one above to upload the edited files when you have made updates.</p> +<h3>Password-less authentication</h3> +<p>To avoid having to manually input your password each upload, you can set up <a href="sshkeys.html">SSH keys</a> to securely idenitify yourself and computer as a trusted.</p> +<h3>Picky trailing slashes</h3> +<p>rsync is very particular about trailing slashes. This is useful, but can be confusing to some new users. Suppose we run the following wanting to mirror our offline copy of our website in the directory we use on our server (<code>/var/www/websitefiles/</code>):</p> +<pre><code>rsync -ruvzP ~/<strong>websitefiles/</strong> root@example.org:/var/www/<strong>websitefiles/</strong></code></pre> +<p>This will <em>not actually do quite what we want</em>. It will take our local <code>websitefiles</code> directory and put it <em>inside</em> <code>websitefiles</code> on the remote machine, ending up with: <code>/var/www/websitefiles/websitefiles</code>.</p> +<p>Instead, remove the trailing slash from the remote server location:</p> +<pre><code>rsync -ruvzP ~/<strong>websitefiles/</strong> root@example.org:/var/www/<strong>websitefiles</strong></code></pre> +<p><code>websitefiles/</code> has been replaced with <code>websitefiles</code>, and this will do what we want.</p> +<h2 id="downloading-file-with-rsync">Downloading files with rsync</h2> +<p>You may just as easily download files and directories from your server with rsync:</p> +<pre><code>rsync -urvzP <strong>root@example.org:/path/to/file</strong> <strong>/path/to/file</strong></code></pre> +<h2 id="contribution">Contribution</h2> +<ul><li>el3ctr0lyte: <a href="https://github.com/el3ctr0lyte">github</a>, XMR: <code class=crypto>86DBJdiG83ZDea6kJgsbVN5tMae5ScfuhJ3PihEMTHatCrGEw2gctyUB92V2fz4R4YhwRaQeAGL5M4gPRXvVvtkULJi4ayk</code></li><li>Substantial revisions by <a href="https://lukesmith.xyz">Luke</a></li></ul> +</main> +]]></description> +</item> + + +<item> <title>Setup a Pleroma Server</title> <guid>https://landchad.net/pleroma.html</guid> <link>https://landchad.net/pleroma.html</link> diff --git a/rsync.html b/rsync.html new file mode 100644 index 0000000..a02d17f --- /dev/null +++ b/rsync.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<html lang=en> + <head> + <title>Rsync: Upload and Sync Files and Websites – LandChad.net</title> + <meta charset="utf-8"/> + <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> + <link rel='stylesheet' type='text/css' href='style.css'> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'> + </head> +<body> + +<header><h1>Rsync: Upload and Sync Files and Websites</h1></header> +<nav></nav> +<main> + <p>rsync is a simple way to copy files and folders between your local computer and server.</p> + <p>It not only makes file-transfer easy, but it allows you to build and maintain your website offline, then easily upload it to the proper directory on your server so you don't need to constantly be logged into your server to modify your site.</p> +<h2 id="installing-rsync">Installing rsync</h2> +<p>Run the following on your server <em>and</em> on your local machine.</p> +<pre><code>apt install rsync</code></pre> +<h2 id="uploading-files-with-rsync">Uploading files with rsync</h2> +<p>From your local machine you can upload files to your server like this:</p> +<pre><code>rsync -rtvzP <strong>/path/to/file</strong> <strong>root@example.org:/path/on/the/server</strong></code></pre> +<p>You will be prompted for the root password and then uploading will commence.</p> +<p>If you omit <strong>root@</strong>, rsync will not attempt to log in as root, but whatever your local username is.</p> +<h3>Options to rsync</h3> +<p>In this command, we give several options to rsync:</p> +<ul> + <li><code>-r</code> – run recurssively (include directories)</li> + <li><code>-t</code> – transfer modification times, which allows skipping files that have not been modified on future uploads</li> + <li><code>-v</code> – visual, show files uploaded</li> + <li><code>-z</code> – compress files for upload</li> + <li><code>-P</code> – if uploading a large file and upload breaks, pick up where we left off rather than reuploading the entire file</li> +</ul> +<p>Avoid using the commonly used <code>-a</code> option when uploading. It can transfers your local machine's user and group permissions to your server, which might cause breakage.</p> +<h3>Scriptability</h3> +<p>It's a good idea to build your website offline, then make an rsync script or bash alias like the one above to upload the edited files when you have made updates.</p> +<h3>Password-less authentication</h3> +<p>To avoid having to manually input your password each upload, you can set up <a href="sshkeys.html">SSH keys</a> to securely idenitify yourself and computer as a trusted.</p> +<h3>Picky trailing slashes</h3> +<p>rsync is very particular about trailing slashes. This is useful, but can be confusing to some new users. Suppose we run the following wanting to mirror our offline copy of our website in the directory we use on our server (<code>/var/www/websitefiles/</code>):</p> +<pre><code>rsync -rtvzP ~/<strong>websitefiles/</strong> root@example.org:/var/www/<strong>websitefiles/</strong></code></pre> +<p>This will <em>not actually do quite what we want</em>. It will take our local <code>websitefiles</code> directory and put it <em>inside</em> <code>websitefiles</code> on the remote machine, ending up with: <code>/var/www/websitefiles/websitefiles</code>.</p> +<p>Instead, remove the trailing slash from the remote server location:</p> +<pre><code>rsync -rtvzP ~/<strong>websitefiles/</strong> root@example.org:/var/www/<strong>websitefiles</strong></code></pre> +<p><code>websitefiles/</code> has been replaced with <code>websitefiles</code>, and this will do what we want.</p> +<h2 id="downloading-file-with-rsync">Downloading files with rsync</h2> +<p>You may just as easily download files and directories from your server with rsync:</p> +<pre><code>rsync -rtvzP <strong>root@example.org:/path/to/file</strong> <strong>/path/to/file</strong></code></pre> +<h2 id="contribution">Contribution</h2> +<ul><li>el3ctr0lyte: <a href="https://github.com/el3ctr0lyte">github</a>, XMR: <code class=crypto>86DBJdiG83ZDea6kJgsbVN5tMae5ScfuhJ3PihEMTHatCrGEw2gctyUB92V2fz4R4YhwRaQeAGL5M4gPRXvVvtkULJi4ayk</code></li><li>Substantial revisions by <a href="https://lukesmith.xyz">Luke</a></li></ul> +</main> +<footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer> +</body> +</html> diff --git a/server.html b/server.html index aa8182f..eadae4b 100644 --- a/server.html +++ b/server.html @@ -38,7 +38,7 @@ <p> The VPS provider that I'll be using for this guide is Vultr, since that is what I use. Vultr provides a free one-month $100 credit to anyone who starts an account through <a href="https://www.vultr.com/?ref=8384069-6G">this referral link of mine</a> - so you can play around with their servies with impunity. + so you can play around with their services with impunity. </p> <h2>Starting your server in two minutes or less</h2> @@ -73,7 +73,7 @@ <p> I especially recommend <strong>Debian 10</strong> for an operating system for your server. Debian is the "classic" server OS and as such, <strong>I make my guides on this site for Debian 10</strong>. - If you use another OS, just know that your milage may vary in terms of you might need to change some instructions here minorly. + If you use another OS, just know that your millage may vary in terms of you might need to change some instructions here minorly. </p> <h4>Server size</h4> @@ -53,7 +53,7 @@ ufw enable</code></pre> <aside> <code>ufw</code> has an internal list of protocols applications, and the ports used by them. - In this case, it knwos SSH is on port 22. + In this case, it knows SSH is on port 22. We'll go more in detail how to view all protocols <code>ufw</code> knows about. By default, when you allow an incoming port, it allows that port both on IPv4 and IPv6. </aside> @@ -13,6 +13,8 @@ <nav></nav> <main> + <img class=titleimg src="pix/xmpp.svg" alt="XMPP Logo and Icon"> + <p>XMPP is a fantastically simple protocol that's usually used as a messenger. It's highly extensible, better than IRC, @@ -49,10 +51,10 @@ Find the line that says <code>admins = { }</code> and to this we can specify one </p> <pre><code># To add one admin: -admins = { "chad@landchad.net" } +admins = { "chad@example.org" } # We can add more than one by separating them by commas. (This file is written in Lua.) -admins = { "chad@landchad.net", "chadmin@landchad.net" }</code></pre> +admins = { "chad@example.org", "chadmin@example.org" }</code></pre> <p> Note that we have not created these accounts yet, we will do this <a href=#user>below</a>. @@ -62,7 +64,7 @@ Note that we have not created these accounts yet, we will do this <a href=#user> <p> Find the line <code>VirtualHost "localhost"</code> and replace <code>localhost</code> with your domain. -In our case, we will have <code>VirtualHost "landchad.net"</code> +In our case, we will have <code>VirtualHost "example.org"</code> </p> <h3>Multi-User Chats</h3> @@ -73,7 +75,8 @@ This is easily enough to enable. In the config file, add the following: </p> -<pre><code>Component "<strong>chat.landchad.xyz</strong>" "muc" +<pre><code>Component "<strong>chat.example.org</strong>" "muc" + modules_enabled = { "muc_mam" } restrict_room_creation = "admin"</code></pre> <p> @@ -93,28 +96,6 @@ Read more about the <code>muc</code> plugin on the Prosody documentation page <a </p> </aside> - -<h3>End-to-end Encryption</h3> - -<p> -Importantly, we'll want end-to-end encryption enabled for user privacy. -</p> - -<p> -Find the array beginning with <code>modules_enabled</code>. -This includes a list of modules to be used. -Add -<code>"omemo_all_access";</code> to that list. -</p> - -<p> -This module is not installed by default, -but you can easily download it by running the following command on the command prompt -to download and install the module to the correcy directory. -</p> - -<pre><code style=font-size:x-small>curl -sL https://hg.prosody.im/prosody-modules/raw-file/785389a2d2b3/mod_omemo_all_access/mod_omemo_all_access.lua > /usr/lib/prosody/modules/mod_omemo_all_access.lua</code></pre> - <h3>Other things to check</h3> <p>Check the config file for other settings you might want to change. @@ -130,22 +111,10 @@ Nowadays, use can use Certbot to generate certificates and use a convenient comm <p> <strong>If you have multi-user chat enabled, be sure to get a certificate for that subdomain as well.</strong> -I usually just create a dummy nginx site for each and run it with the <code>--nginx</code> option. -This makes auto-renewal a little easier. +Include the <code>--nginx</code> option assuming you have an Nginx server running. </p> -<!-- <pre><code>server { --> -<!-- listen 80 ; --> -<!-- listen [::]:80 ; --> -<!-- root /var/www/html; --> -<!-- index index.html index.htm index.nginx-debian.html; --> -<!-- server_name <strong>muc.landchad.net</strong> ; --> -<!-- location / { --> -<!-- try_files $uri $uri/ =404; --> -<!-- } --> -<!-- }</code></pre> --> - -<pre><code>certbot --nginx</code></pre> +<pre><code>certbot -d <strong>chat.example.org</strong> --nginx</code></pre> <p> Once you have the certificates for encryption, run the following to import them into Prosody. @@ -170,7 +139,7 @@ Let's manually create the admin user we prepared for above. Note that you can indeed do this in your XMPP client if you have not disabled registration, but this is how it is done on the command line: </p> -<pre><code>prosodyctl adduser chad@landchad.net</code></pre> +<pre><code>prosodyctl adduser <strong>chad@example.org</strong></code></pre> <p>This will prompt you to create a password as well.</p> @@ -181,7 +150,41 @@ Note that you can indeed do this in your XMPP client if you have not disabled re With any system service, use <code>systemctl reload</code> or <code>systemctl restart</code> to make the new settings active: </p> -<pre><code>systemctl reload prosody</code></pre> +<pre><code>systemctl restart prosody</code></pre> + +<h2>Using your Server!</h2> + +<p> +Once your server is set up, you just need an XMPP client to use your new and secure chat system. +</p> + +<ul> + <li>GNU/Linux: <a href="https://dino.im/">Dino</a> or <a href="https://gajim.org/">Gajim</a></li> + <li>Windows: <a href="https://gajim.org/">Gajim</a> also runs on Windows.</li> + <li>Android: <a href="https://conversations.im/">Conversations.im</a></li> + <li>Mac/iOS: <a href="https://monal.im/">Monal IM</a> or <a href="https://siskin.im/">Siskin</a> for iOS alone</li> + <li>command-line (GNU/Linux, MacOS, Windows): <a href="https://profanity-im.github.io/">Profanity</a></li> + <li><a href="https://xmpp.org/software/clients.html">See a more complete list kept by XMPP</a></li> +</ul> + +<p> +Install whichever of these clients you want on your computer or phone and you can log into your new XMPP server with the account you made. +Note that if you enabled public registration, anyone can create an account on your server through one of these clients. +</p> + +<h3>Account addresses</h3> + +<p> +XMPP account addressed look just like email addresses: <code><strong>username@example.org</strong></code>. +You can message any account on any XMPP server on the internet with that format. +</p> + +<h3>Note on MUCs (multi-user chats)</h3> + +<p> +Remember that MUCs are kept on a separate subdomain that we created and should've gotten a certificate for above, for example, <code><strong>chat.example.org</strong></code>. +Chatrooms are created and referred to in the following format: <code><strong>#chatroomname@chat.example.org</strong></code>. +</p> </main> <footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer> |
