diff options
Diffstat (limited to 'rss.xml')
| -rw-r--r-- | rss.xml | 861 |
1 files changed, 859 insertions, 2 deletions
@@ -16,6 +16,864 @@ <!-- LB --> <item> +<title>Setting up Cgit</title> +<guid>https://landchad.net/cgit.html</guid> +<link>https://landchad.net/cgit.html</link> +<pubDate>Tue, 14 Sep 2021 14:06:48 -0400</pubDate> +<description><![CDATA[ + <header> + <h1>Setting up Cgit</h1> + <img src="pix/cgit.svg" class="titleimg"> + </header> + <main> + <p> + Once you have your server hosting your git repositories, you might want to allow others to browse + your repositories on the web. Cgit is a Free Software that allows browsing git repositories through + the web. </p> + <p> + Note that Cgit is a read-only frontend for Git repositories and doesn't have issues, pull requests + or user management. If that's what you want, consider installing Gitea instead.</p> + <h2>Installing cgit and fcgiwrap</h2> + <h3>Install fcgiwrap</h3> + <p> + NGINX doesn't have the capability to run CGI scripts by itself, it depends on an intermediate layer + like fcgiwrap to run CGI scripts like cgit:</p> + <pre><code>apt install fcgiwrap</code></pre> + <p>And now we can install cgit itself with:</p> + <pre><code>apt install cgit</code></pre> + <h2>Setting up NGINX</h2> + <p> + You should have an NGINX server running with a TLS certificate by now. Add the following configuration + to your server to pass the requests to Cgit, while serving static files directly:</p> + <pre><code> +server { + listen 443 ssl; + listen [::]:443 ssl; + ssl_certificate /etc/ssl/nginx/<strong>git.example.org</strong>.crt; + ssl_certificate_key /etc/ssl/nginx/<strong>git.example.org</strong>.key; + server_name <strong>git.example.org</strong>; + root /usr/share/cgit ; + try_files $uri @cgit ; + location @cgit { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi; + fastcgi_param PATH_INFO $request_uri; + fastcgi_param QUERY_STRING $query_string; + fastcgi_pass unix:/run/fcgiwrap.socket; + } +} + </code></pre> + <p>Then get NGINX to reload your configuration.</p> + <h2>Configuring cgit</h2> + <p>You've got cgit up and running now, but you'll probably see it without any style and without any repository. + To change this, we need to configure Cgit to our liking, by editing <code>/etc/cgitrc</code>. + </p> + <pre><code> +css=/cgit.css +logo=/cgit.svg +virtual-root=/ +# Title and description shown on top of each page +root-title=<strong>Chad's git server</strong> +root-desc=<strong>A web interface to LandChad's git repositories, powered by Cgit</strong> +# The location where git repos are stored on the server +scan-path=/srv/git/ + </code></pre> + <p>This configuration assumes you followed the <a href="/git">git hosting guide</a> and store your repositories + on the <code>/srv/git/</code> directory.</p> + <p>Cgit's configuration allows changing many settings, as documented on the cgitrc(5) manpage installed with + Cgit.</p> + <h3>Changing the displayed repository owner</h3> + <p>Cgit's main page shows each repo's owner, which is "git" in case you followed the git hosting guide, but you + might want to change the name to yours. Cgit shows the owner's system name, so you need to modify the git + user + to give it your name:</p> + <pre><code> +usermod -c "<strong>Your Name</strong>" git + </code></pre> + <h3>Changing the repository description</h3> + <p>Navigate to your bare repository on the server and edit the <code>description</code> file inside it</p> + <h3>Displaying the repository idle time</h3> + <p>To do this, we need to create a post-receive hook for each repository that updates the file cgit uses + to determine the idle time. Inside your repository, create a file <code>hooks/post-receive</code> and add + the following contents:</p> + <pre><code> +#!/bin/sh +agefile="$(git rev-parse --git-dir)"/info/web/last-modified +mkdir -p "$(dirname "$agefile")" && +git for-each-ref \ + --sort=-authordate --count=1 \ + --format='%(authordate:iso8601)' \ + >"$agefile" + </code></pre> + <p>And give it execution permissions with:</p> + <pre><code>chmod +x hooks/post-receive</code></pre> + <p>Next time you push to that repository, the idle time should reset and show the correct value.</p> + <h2>Contribution</h2> + <ul> + <li>Ariel Costas – <a href="https://costas.dev">website</a>, <a + href="https://costas.dev/donations/">donations</a></li> + </ul> + </main> + +]]></description> +</item> + + +<item> +<title>Self hosting</title> +<guid>https://landchad.net/selfhosting.html</guid> +<link>https://landchad.net/selfhosting.html</link> +<pubDate>Sun, 29 Aug 2021 15:35:48 -0400</pubDate> +<description><![CDATA[ + <header><h1>Self hosting</h1></header> + + <main> + <h2>Introduction</h2> + <p>When you have a(n old) computer lying around, and you have cheap electricity and a good internet connection, self hosting might be a good option for you.</p> + <h3>Why would you choose selfhosting?</h3> + <ul> + <li> + You have control over the hardware, and you can upgrade your server in the future. For example: if you host a file server and your hard drive goes full, you can simply add another hard drive or upgrade it. + </li> + <li> + No bandwith limits, storage limits, etc. (some VPSes have this) + </li> + <li> + It <strong>can</strong> be cheaper than using a VPS. This only is the case if you got the server for really cheap and your electricity is cheap. + </li> + <li> + You can have a media server to consoom your content (for example with <code>Jellyfin</code>). You can technically do this on a VPS, but that will be more expensive than self hosting. If you have a media server, you can stream media from your server to more devices. (I recommend just downloading it on your device, but if you have multiple devices, this could be a good solution) + </li> + </ul> + + <h3>Downsides</h3> + <p>Some possible downsides of choosing to host at home could be:</p> + <ul> + <li> + Your ISP not approving of what you're doing. Some ISP's do not condone you hosting at home. Usually when this is the case, it could be harder if you want to forward ports, or it could be impossible to get a static IP address. Check your ISP's terms of service. Sometimes, it will say that hosting a webserver, email server, and more, is not allowed. + </li> + <li> + This can also include blocked ports. ISPs can block certain ports to the world. Sometimes ISPs only block 445/139 (which is for the better as Samba, using these ports isn't really secure and it's outdated). But some ISPs (sadly) block crucial ports like 80 and/or 443. You need to check this before trying anything. If this is the case, a way to get around it is to get another ISP or use an alternative port. A great website to check this is: <a href="https://canyouseeme.org/">canyouseeme.org</a>. You can also check if you did the port forwaring correctly here.</li> + <li> + Security. Opening your network to the public could bring security risks. For example, never open a Samba server to the public, because it's a pretty old protocol, and it has some security vulnerabilities. Be sure you are forwarding the right port, and don't just forward random ports to the internet. Also, if you are getting DDoSed, your ISP will temporarily shut down your whole internet connection. + </li> + <li> + When setting up an email server, it can be way harder to not have your email show up as spam in other's people email. If you use a VPS, this is way easier. + </li> + <li> + Space, power consumption and noise. Of course, this differs per server. + </li> + </ul> + <p>Your mileage may vary, go and check each of these points, and see if selfhosting is the right choice for you. Try and calculate your power consumption and see if your electricity cost is not too expensive.</p> + <p>For me, the upsides outweighed the downsides, which is why I chose to host at home. But, this differs with each person and scenario. Go and research what your exact situation is, before trying anything. Otherwise you'll have to face some bad surprises.</p> + <h2>Hardware</h2> + + <h3>What kind of hardware should you choose?</h3> + <p>If you pay your own electricity bill, power consumption is a big factor. Most old laptop computers are ideal in the sense that they don't use a lot of power, and if the battery still works, you have a built-in UPS! The bad thing is, most old laptop computers aren't that powerful, and they lack in upgradability. (you shouldn't really be using anything older than 2006, and I recommend at least a performance equivalant of a Core 2 CPU) + </p> + <p>If you can find an energy efficient desktop (under 100W), that is a great option. They are pretty upgradable and they don't use a lot of power. They can also be pretty cheap, but old laptops are usually cheaper. If you can afford new hardware, and are willing to build a PC, you can find really power effecient CPU/motherboard combos, and they can be cheap, for example the Celeron J3060. I recommend a low wattage power supply or an effecient one for these kinds of builds. Pico PSUs are pretty tiny and efficient solutions in these builds.</p> + <p>Of course, if you don't pay your electricity bill or cost is not a problem for you, you can use just about any old desktop (as long as it's not from the 90's, I recommend at least a Core 2 chip again, or an Athlon 64 X2).</p> + <h3>Usecases</h3> + <p>Of course, hardware choices depend on the usecase. The above recommendations I gave you work fine for e-mail server, webserver and fileserver types of applications, but they will struggle to transcode video if you are going to host a media server. You'll need a faster CPU, but also a faster GPU. As an example, the Athlon 200GE or 3000G are good and efficient choices for these builds. They are decent CPUs, but also have a built in GPU that will transcode video just fine.</p> + <p> + If you need a lot of storage, go for a case with a lot of mounts for hard drives, this way you can easily mount multiple hard drives. Pros of multiple hard drives are redundancy and speed. Cons could be that they create more heat and noise. You can't use a laptop if you want multiple drives, except if you use a hard drive caddy for the CD/DVD drive bay. Some business laptops even support RAID 1 (redundancy) and RAID 0 (speed and more storage, but you lose your files if one hard drive breaks) this way.</p> + <h2>Getting started</h2> + <h3>Installing Debian</h3> + <p>Once you have the machine, you can install the OS. I recommend Debian, as all of the guides on this website are Debian specific. Debian just werks as a server OS.</p> +</p> +<p>You'll need to burn a Debian install image onto a USB flash drive or a CD. You can download the image <a href="https://www.debian.org/CD/netinst/">here</a>, and you can also find information on how to burn the image onto a USB flash drive or CD there. +</p> +<p>While installing Debian, do not install any desktop environment. But install an SSH server when you get the chance. Also leave webserver unchecked, even if you want to use it as a webserver. You'll have a chance to install this later.</p> +<h3>Port forwaring</h3> +<p>Every time you are going to set up a new server program, you need to forward a port corresponding to that program. For example, HTTP is port 80, HTTPS is 443, etc. You need to set this up on your router's NAT settings (sometimes just called port forwarding, this differs per router). These steps differ for each router. Refer to your routers manual. A simple command to see what your servers IP address is, is to run <code>ifconfig</code> on your server. This shows a lot of network info, but it will also show your local IP address needed for port forwarding. +</p> +<p>Basic ports:</p> +<ul> + <li> + SSH: port 22 (open this port if you want to admin your server outside your network) + </li> + <li> + HTTP: port 80 (open this port if you want basic webserver functionality) + </li> + <li> + HTTPS: port 443 (you should open this port if you are setting up a webserver because encryption) + </li> + </ul> + +<h3>Static or dynamic IP address</h3> +<p>If you want to host your server at home, make sure you have a static IP address, or you can change your dynamic IP address to a static one. Refer to your router settings, some ISPs will have options on this here. If you can't find anything on this, get in touch with your ISP.</p> +<p>Once you've made sure you have a static IP address, you can find out what the IP address is with various websites. You can use a search engine to easily find this out. Write this down as you'll need it later.</p> +<p>Once you're done, you can pretty much follow every guide on this website, the only difference is that you'll need to forward the ports you'll be using for the server.</p> +<h3>Finding the ports you'll need to forward</h3> +<p>If you need to know what port you'll need to forward, there's a command for that. Just type <code>netstat -tulpn</code> in your servers command line. If you want to see the name of the programs, you need to run it as a root user. You can do this by putting <code>sudo</code> before the command.</p> +<pre><code>Local Address State PID/Program name +0.0.0.0:25 LISTEN 887/master +0.0.0.0:1883 LISTEN 22452/mosquitto +0.0.0.0:445 LISTEN 798/smbd +0.0.0.0:993 LISTEN 381/dovecot +127.0.0.1:3306 LISTEN 560/mysqld +0.0.0.0:587 LISTEN 887/master +0.0.0.0:139 LISTEN 798/smbd +127.0.1.1:12301 LISTEN 412/opendkim +0.0.0.0:143 LISTEN 381/dovecot +0.0.0.0:465 LISTEN 887/master +0.0.0.0:22 LISTEN 472/sshd +:::25 LISTEN 887/master +:::443 LISTEN 1769/apache2 +:::1883 LISTEN 22452/mosquitto +:::445 LISTEN 798/smbd</code></pre> +<p><em>Example output</em></p> + +<p>In this example, if you need to find the port number from <code>dovecot</code>, you can look for it in the <code>Program name</code> column. Then you can see in the local address column that the reported local address is <code>0.0.0.0:993</code>. You need to look for the part after the semicolon. In this case it's 993. So you'll need to forward port 993.</p> + +<span class="next"><a href="dns.html">Next: Connect Your Domain and Server</a></span> + +<hr> +<p><em>Written by <a href="https://github.com/hidde-j">hiddej</a></em> + </main> +]]></description> +</item> + + +<item> +<title>Mirror your site over I2P</title> +<guid>https://landchad.net/i2p.html</guid> +<link>https://landchad.net/i2p.html</link> +<pubDate>Sun, 29 Aug 2021 15:32:44 -0400</pubDate> +<description><![CDATA[ + <header><h1>Mirror Your Site Over I2P</h1></header> + + <main> + <img class=titleimg src="pix/i2p.svg" alt="I2P logo"> + <p> + Now you have a website, why not offer it in a private alternative such as the Invisible Internet? + </p> + <h2>Setting up I2P</h2> + <p> + There are 2 main I2P implementations, I2P and i2pd, we are using i2pd in this + guide because it's easier to use in servers. + </p> + <h3>Installing I2P</h3> + <p> + i2pd is in most repos, in debian/ubuntu you can install it simply + with <pre><code>apt install i2pd</code></pre> + </p> + <h3>Enabling I2P</h3> + <p> + We are going to create a user for i2pd, because i2pd finds the configuration + files in its home directory. And it's easier (and more tidy) to have it in a separate user: + </p> + <pre><code>useradd -m i2p -s /bin/bash +su -l i2p +mkdir ~/.i2pd +cd ~/.i2pd</code></pre> + <p> + Now that you're in ~/.i2pd, you have to create a file named + "tunnels.conf". Which is the config file for every hidden service you're + offering over I2P, the content should be like this: + </p> + <pre><code>[<strong>example</strong>] +type = http +host = 127.0.0.1 +port = 8080 +keys = <strong>example.dat</strong></code></pre> + <h3>Getting your I2P Hostname</h3> + <p> + Then, run <code>/usr/sbin/i2pd --daemon</code> to start i2pd and we can retreive our I2P hostname. + </p> + <p> + This can be done in lynx or a command-line browser by going to <code>http://127.0.0.1:7070/?page=i2p_tunnels</code> to get your I2P hostname. + </p> + <p> + You + can also run these commands to find your hostname: + </p> + <pre><code>printf "%s.b32.i2p +" $(head -c 391 /home/i2p/.i2pd/<strong>example.dat</strong> |sha256sum|xxd -r -p | base32 |sed s/=//g | tr A-Z a-z)</code></pre> + <h2>Adding the Nginx Config</h2> + <p> + From here, the steps are almost identical to setting up a normal website configuration file. + Follow the steps as if you were making a new website on the webserver + <a href="nginx.html">tutorial</a> up until the server block of code. Instead, paste this: + </p> + <pre><code>server { +listen 127.0.0.1:8080 ; +root /var/www/<strong>example</strong> ; +index index.html ; +}</code></pre> + <aside> + <h4>Clarifications<h4> + <p> + Nginx will listen in port 8080, but i2pd will forward your port + 8080 to the i2p site port 80. This way you don't have to deal with server names or anything like that + </p> + </aside> + <p> + From here we are almost done, all we have to do is enable the site and reload nginx which is also covered in <a href="nginx.html#enable">the webserver tutorial</a>. + </p> + <h3>Update regularly!</h3> + <p>Make sure to update I2P on a regular basis by running:</p> + <pre><code>apt update && apt install i2pd</code></pre> + <p><strong>Contributor</strong> - <a href="https://qorg11.net" target="_blank">qorg11</a></p> + </main> + + +]]></description> +</item> + + +<item> +<title>Setting up a Calibre library server</title> +<guid>https://landchad.net/calibre.html</guid> +<link>https://landchad.net/calibre.html</link> +<pubDate>Tue, 03 Aug 2021 13:49:21 -0400</pubDate> +<description><![CDATA[ + <header><h1>Setting up a Calibre library server</h1></header> + + <main> + <img src="pix/calibre.png" alt="Calibre logo" class=titleimg> + <p> + The Calibre library server is a great way to store your eBooks. + It allows you to: + </p> + <ul> + <li>Share your books with others.</li> + <li>Easily transfer your books between devices and access them from anywhere.</li> + </ul> + <h2>Installation</h2> + <p>Install the Calibre package. + You might also want rsync to upload books.</p> + <pre><code>apt install -y calibre rsync +mkdir /opt/calibre</code></pre> + <p> + Either upload your existing library using <code>rsync</code>. For example to <code>/opt/calibre/</code>. + </p> + <p> + On client: + </p> + <pre><code>cd ~/Documents +rsync -avuP <strong>your-library-dir</strong> root@<strong>example.org</strong>:/opt/calibre/</code></pre> + <p> + Or create a library and add a book to it: + </p> +<pre><code>cd /opt/calibre +calibredb add <strong>book.epub</strong> --with-library <strong>your-library</strong></code></pre> + <aside> + <p> + For more information about the <code>calibredb</code> command see <code>man calibredb</code>. + </p> + </aside> + <p> + Add a new user to protect your server: + </p> + <pre><code>calibre-server --manage-users</code></pre> + <h2>Creating a service</h2> + <p> + Create a new file <code>/etc/systemd/system/calibre-server.service</code> and add the following: + </p> +<pre><code>[Unit] +Description=Calibre library server +After=network.target +[Service] +Type=simple +User=root +Group=root +ExecStart=/usr/bin/calibre-server --enable-auth --enable-local-write /opt/calibre/your_library --listen-on 127.0.0.1 +[Install] +WantedBy=multi-user.target +</code></pre> + <aside> + <p> + You can change the port with the <code>--port</code> prefix. Additional information <code>man calibre-server</code>. + </p> + </aside> + <p> + Issue <code>systemctl daemon-reload</code> to apply the changes. + </p> + <p> + Enable and start the service. + </p> +<pre><code>systemctl enable calibre-server +systemctl start calibre-server</code></pre> + <h2>A reverse proxy with Nginx</h2> + <p> + Create a new file <code>/etc/nginx/sites-available/calibre</code> and enter the following: + </p> +<pre><code>server { + listen 80; + client_max_body_size 64M; # to upload large books + server_name <strong>calibre.example.org</strong> ; + location / { + proxy_pass http://127.0.0.1:8080; + } +}</code></pre> + <p>Issue a Let's Encrypt certificate. <a href="certbot.html">Detailed instructions and additional information</a>.</p> + <pre><code>certbot --nginx</code></pre> + <p>Now just go to <strong>calibre.example.org</strong>. The server will request an username and a password.</p> + <a href="pix/calibre-1.png"> + <img src="pix/calibre/calibre-1.png" alt="calibre"> + </a> + <p>After login you will see something like this.</p> + <a href="pix/calibre-1.png"> + <img src="pix/calibre/calibre-2.png" alt="calibre"> + </a> + <h2>Contribution</h2> + <li>Author: rflx – <a href="https://rflx.xyz">website</a> -- XMR: <code class=crypto>48T5XpHTXAZ5Nn8YCypA4aWn1ffQLHJkFGDArXQB6cmrP6cqLY72cu7CR2iq2MmL5Ndu3d47e5MKjGpL4prYgdrTCFAHD9c</code> + </li> + </main> +]]></description> +</item> + + +<item> +<title>Jitsi Video Chat</title> +<guid>https://landchad.net/jitsi.html</guid> +<link>https://landchad.net/jitsi.html</link> +<pubDate>Tue, 03 Aug 2021 13:00:23 -0400</pubDate> +<description><![CDATA[ + <header><h1>Jitsi Video Chat</h1></header> + + <main> + <img src="pix/jitsi.svg" alt="Jitsi" class=titleimg> + <p> + <dfn>Jitsi</dfn> is a set of open-source projects that allows you to easily build and deploy secure video conferencing solutions. + </p> + <p> + Is really easy to install, and also a really good private, federated and libre alternative to Zoom or other video conferencing software. + You can create calls just by typing the URL, and loging-in is not necessary. + </p> + <h2>Dependencies and Installation</h2> + <p>First, install some dependencies:</p> + <pre><code>apt install gpg apt-transport-https nginx python3-certbot-nginx</code></pre> + <p>Jitsi has its own package repository, so let's add it.</p> + <pre class=wide><code>curl https://download.jitsi.org/jitsi-key.gpg.key | gpg --dearmor > /usr/share/keyrings/jitsi-keyring.gpg +echo 'deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/' > /etc/apt/sources.list.d/jitsi-stable.list +apt update -y</code></pre> + <p> + Ok. So now we can install Jitsi, but before we do that, let's the firewall <code>ufw</code>, in case you + have it enabled, and the SSL certificate. + </p> + <h2>Enable Required Ports</h2> + <p>If you are using <a href="ufw.html">ufw</a> or another firewall, there are several ports we need to ensure are open:</p> + <pre><code>ufw allow 80/tcp +ufw allow 443/tcp +ufw allow 10000/udp +ufw allow 3478/udp +ufw allow 5349/tcp +ufw enable</code></pre> + <p>For your information, these allow the following:</p> + <ul> + <li>80 TCP – Certbot.</li> + <li>443 TCP – General access to Jitsi Meet.</li> + <li>10000 UDP – General network video/audio communications.</li> + <li>3478 UDP – Quering the stun server (coturn, optional, needs config.js change to enable it).</li> + <li> + 5349 TCP – Fallback network video/audio communications over TCP (when UDP is blocked for example), served by coturn. + </li> + </ul> + <h2>SSL certificate</h2> + <p> + I'll be using <a href="./certbot.html" target="blank">certbot</a> and + <a href="./nginx.html" target="blank">Nginx</a> to generate a certificate + for the Jitsi subdomain to allow encrypted connections. + </p> + <pre><code>certbot --nginx certonly -d <strong>meet.example.org</strong></code></pre> + <p> + We will not create an Nginx config file for Jitsi because the Jitsi package we will be installing will do that automatically. + </p> + <h2>Installation</h2> + <p>To begin the installation process, just run:</p> + <pre><code>apt install jitsi-meet</code></pre> + <p> + It will ask you for your <code><strong>hostname</strong></code + >; there you'll need to input the subdomain you have just added to Nginx, like + <code><strong>meet.example.org</strong></code>. + </p> + <p>For the SSL certificate, choose <code>I want to use my own certificate</code>.</p> + <p> + When it ask you for the certification key and cert files, input + <code>/etc/letsencrypt/live/<strong>meet.example.org</strong>/privkey.pem</code> and + <code>/etc/letsencrypt/live/<strong>meet.example.org</strong>/cert.pem</code> respectively. + </p> + <h2>Using Jitsi</h2> + <img src="pix/jitsi-01.webp" alt="Jitsi once installed"> + <p>Jitsi can be used in a browser by then just going to <code>meet.example.org</code>.</p> + <p>Note that there are also Jitsi clients for all major platforms:</p> + <ul> + <li><a href="https://desktop.jitsi.org/Main/Download.html">Desktop</a> (Windows, MacOS, GNU/Linux)</li> + <li>Android (<a href="https://f-droid.org/en/packages/org.jitsi.meet/">F-Droid</a> and <a href="https://play.google.com/store/apps/details?id=org.jitsi.meet">Google Play</a>)</li> + <li><a href="https://apps.apple.com/us/app/jitsi-meet/id1165103905">iPhone/iOS</a></li> + </ul> + <p> + <strong>When using a Jitsti app for the first time, remember to go to the "Settings" menu and change your server name to the Jitsi site you just created.</strong> + </p> + <p>When you create a video chatroom, its address will appear as <code><strong>meet.example.org/yourvideochatname</strong></code> and can be shared as such.</p> + <h2>More info</h2> + <p> + This article is based on <a href="https://jitsi.github.io/handbook/docs/devops-guide/devops-guide-quickstart" target="blank">the original documentation</a>. There you can find more details and configurations. + </p> + <ul> + <li>Written by <a href="https://josefabio.com" target="blank">Jose Fabio.</a> Donate Monero: <code class="crypto">484RLdsXQCDGSthNatGApRPTyqcCbM3PkM97axXezEuPZppimXmwWegiF3Et4BHBgjWR7sVXuEUoAeVNpBiVznhoDLqLV7j</code> <a href="https://josefabio.com/figures/monero.jpg" class="crypto" target="blank">[QR]</a></li> + <li>Edited and revised by <a href="https://lukesmith.xyz">Luke</a>.</li> + </ul> + </main> + + +]]></description> +</item> + + +<item> +<title>PeerTube Instance</title> +<guid>https://landchad.net/peertube.html</guid> +<link>https://landchad.net/peertube.html</link> +<pubDate>Thu, 29 Jul 2021 10:44:56 -0400</pubDate> +<description><![CDATA[ + <header><h1>PeerTube Instance</h1></header> + + <main> + <img class=titleimg src="pix/peertube.svg" alt="PeerTube logo"> + <p>PeerTube is a self-hosted and (optionally) federated video sharing platform that saves bandwith on videos the more people watch. + PeerTube instances can follow each other to share videos and grow the federated network, + but you can always keep your instance to yourself if you choose to.</p> + <h2>Prerequisites</h2> + <p><strong>Most</strong> of PeerTube's dependencies can be installed with this command:</p> + <pre><code>apt install -y curl sudo unzip vim ffmpeg postgresql postgresql-contrib g++ make redis-server git python-dev cron wget</code></pre> + <p>It's also important to start all associated daemons:</p> + <pre><code>systemctl start postgresql redis</code></pre> + <p>PeerTube also requires <strong>NodeJS 14</strong> and <strong>yarn</strong> which cannot be installed from the Debian repositories. This means they have to be installed from separate, external repos:</p> + <pre><code>curl -fsSL https://deb.nodesource.com/setup_14.x | bash - +apt install -y nodejs +npm install --global yarn</code></pre> + <p>In addition to these dependencies, it's recommended to create a dedicated PeerTube user to install and manage PeerTube.</p> + <pre><code>useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube</code></pre> + <h2>Database</h2> + <p>PeerTube requires a PostgreSQL database to function. To create it, first make a new Postgres user named PeerTube:</p> + <pre><code>su postgres +createuser -P peertube +createdb -O peertube -E UTF8 -T template0 peertube_prod +psql -c "CREATE EXTENSION pg_trgm;" peertube_prod +psql -c "CREATE EXTENSION unaccent;" peertube_prod +exit</code></pre> + <p>Be sure to <strong>make note of your Postgres user password,</strong> as it will be needed later when setting up PeerTube.</p> + <h2>Installation</h2> + <p>This handy one-liner can be used to determine the latest PeerTube version:</p> + <pre><code>VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest Peertube version is $VERSION"</code></pre> + <p>Next, a basic directory structure needs to be setup in the PeerTube user's home directory (/var/www/peertube).</p> + <p>To ensure permissions remain the same while managing files as PeerTube, <code>sudo</code> can be used to perform actions:</p> + <pre><code>sudo -u peertube mkdir config storage versions +sudo -u peertube chmod 750 config</code></pre> + <p>Finally, a PeerTube release can be downloaded from the GitHub page and installed using yarn:</p> + <pre><code>cd versions +sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest +cd ./peertube-latest && sudo -H -u peertube yarn install --production --pure-lockfile</code></pre> + <h2>Configuration</h2> + <p>PeerTube's default config file can be copied over to <code>/var/www/peertube/config.production.yaml</code> so it can actually be used:</p> + <pre><code>cd /var/www/peertube + sudo -u peertube cp peertube-latest/production.yaml config/production.yaml</code></pre> + <p>Now the <code>production.yaml</code> file must be edited in the following ways:</p> + <p>First, add the hostname:</p> + <pre><code>webserver: + https: true + hostname: <strong>'example.org'</strong> + port: 443</code></pre> + <p>Then, the database:</p> + <pre><code>database: + hostname: 'localhost' + port: 5432 + ssl: false + suffix: '_prod' + username: <strong>'peertube'</strong> + password: <strong>'your_password'</strong> + pool: + max: 5</code></pre> + <p>An email to generate the admin user:</p> + <pre><code>admin: + # Used to generate the root user at first startup + # And to receive emails from the contact form + email: <strong>'chad@example.org'</strong></code></pre> + <p>And <strong>optionally,</strong> email server information:</p> + <pre><code>smtp: + # smtp or sendmail + transport: smtp + # Path to sendmail command. Required if you use sendmail transport + sendmail: null + hostname: <strong>mail.example.org</strong> + port: 465 # If you use StartTLS: 587 + username: <strong>your_email_username</strong> + password: <strong>your_email_password</strong> + tls: true # If you use StartTLS: false + disable_starttls: false + ca_file: null # Used for self signed certificates + from_address: <strong>'admin@example.org'</strong></code></pre> + <h2>NGINX</h2> + <p>PeerTube includes an NGINX configuration that can be copied over to <code>/etc/nginx/sites-available:</code> + <pre><code>cp /var/www/peertube/peertube-latest/support/nginx/peertube /etc/nginx/sites-available/peertube</code></pre> + <p>Because the PeerTube config is so long, it's recommended to use <code>sed</code> to modify the contents of the file, + replacing <code>${WEBSERVER_HOST}</code> with your hostname, + and <code>$(PEERTUBE_HOST)</code> with your localhost and port, which by default should be <code>127.0.0.1:9000</code>: + <pre><code>sed -i 's/${WEBSERVER_HOST}/<strong>example.org</strong>/g' /etc/nginx/sites-available/peertube +sed -i 's/${PEERTUBE_HOST}/127.0.0.1:9000/g' /etc/nginx/sites-available/peertube</code></pre> + <p>Once you're happy with the NGINX config file, link it to <code>sites-enabled</code> to activate it:</p> + <pre><code>ln -s /etc/nginx/sites-available/peertube /etc/nginx/sites-enabled/peertube</code></pre> + <h3>Encryption with Certbot</h3> + <p>It's <strong>highly recommended</strong> to generate certificates for use with your PeerTube site, and this can be easily done with Let's Encrypt's <code>certbot</code> command:</p> + <pre><code>systemctl stop nginx +certbot certonly --standalone -d <strong>example.org</strong> +sudo systemctl restart nginx</code></pre> + <p>The certificates are generated <strong>standalone</strong> since the PeerTube NGINX config file already includes configuration for certbot.</p> + <h2>Running PeerTube</h2> + <p>A config file for a systemd daemon is included in PeerTube and can be setup like so:</p> + <pre><code>cp /var/www/peertube/peertube-latest/support/systemd/peertube.service /etc/systemd/system/ +systemctl daemon-reload</code></pre> + <p>Now, finally, run the PeerTube daemon to start PeerTube:</p> + <pre><code>systemctl start peertube</pre></code> + <h2>Using PeerTube</h2> + <p>To set a password for your admin user, run:</p> + <pre><code>cd /var/www/peertube/peertube-latest && NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u root</code></pre> + <p>Login to your PeerTube instance using the admin email specified in your <code>production.yaml</code> file and the admin password you just set.</p> + <img src="pix/peertube-login.jpg" height=400px> + <p>Once logged in, it's recommended to create a separate user without admin privileges for uploading videos to PeerTube. + This can be done easily from the users tab in the administration section:</p> + <p>Enjoy your PeerTube instance!</p> + <hr> + <h2>Updating PeerTube</h2> + <p>PeerTube is constantly adding new features, so it's a good idea to <a href="https://github.com/Chocobozzz/PeerTube/blob/develop/CHANGELOG.md">check for new updates</a> and add them if you wish. Just in the past year, they have added livestreaming and more.</p> + <p>Updating is fairly easy now since an <code>upgrade.sh</code> script has been added. Just run:</p> + <pre><code>cd /var/www/peertube/peertube-latest/scripts && sudo -H -u peertube ./upgrade.sh</code></pre> + <p> + Although check the <a href="https://github.com/Chocobozzz/PeerTube/blob/develop/CHANGELOG.md">changelog</a> to see if there are additional manual requirements for particular updates. + </p> + <hr> + <p><em>Written by <a href="https://denshi.live">Denshi.</a> Donate Monero <a href="https://denshi.live/donate.html">here</a> <a href="https://denshi.live/images/monero.png">[QR]</a></em></p> + </main> + +]]></description> +</item> + + +<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/donate.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> @@ -1423,8 +2281,7 @@ mkdir git</code></pre> </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> + <li>Martin Chrzanowski -- <a href="https://m-chrzan.xyz">website</a>, <a href="https://m-chrzan.xyz/donate.html">donate</a></li> </ul> </main> |
