Raspberry Pi web server You
don't have to buy an account from a hosting provider to make information publicly available. There are many alternative options, including free ones. There are free hosting sites for text, images and files starting with Github Pages .
And if we want to keep the site completely under our control, we can host a web server on a home computer, a Raspberry Pi single board, or even on a mobile phone. The main thing is that the device is online all the time.
Web server on home computer
Home server in a vintage case, source An
old computer can always be used: it can work as a torrent client and a media server (distributing video through Plex to all TVs, laptops and smartphones), as a file storage, archive of backups, and also as a web server ... It couldn't be easier.
Of course, for a standard software stack, it is better to install Linux, but there is nothing wrong with Windows. At least 29.2% of servers on the Internet run Windows , so it is not necessary to change the operating system if the computer was originally installed, especially if you are used to working with tools such as ASP.NET and C.
For simplicity, you can immediately install the entire set of programs. Choosing one of the AMP stacks(Apache, MySQL / MariaDB, Perl / PHP / Python) for any platform: Windows, macOS, Linux, BSD. For example, the WampServer suite for Windows.
WampServer is a Windows web development platform for dynamic web applications using Apache2 server, PHP script interpreter and MySQL database. It also includes a PHPMyAdmin web application for simple database handling.
We install the software, get an external IP address from the provider, write a domain name in the configuration, open ports 80, 3306 (MySQL), 21 (FTP), 22 (SSH) in the router or change them to non-standard ones to reduce garbage traffic from crawler bots - and everything should work.
For more information, see the article "Bedside Hosting: The Creepy Practice of Home Hosting" anda large list of software that can be deployed on your own hosting.
Raspberry Pi Hosting
The algorithm is clear: you need to set up a web server on the Raspberry Pi and connect it to the network. This is not some kind of exotic, but quite regular use of "raspberry". The official website even has instructions for installing Apache and Nginx .
Alternatively, the web server can be raised directly on the router (with OpenWRT firmware).
After setting Nginx check the availability of the site on the address
http://localhost/
for the Pi or IP-address of a device within the network, for example http://192.168.1.10
. You can find out your internal IP address with the command hostname -I
.
Web pages are stored in the directory by default
/var/www/html
. We go there and place anything, replacing the standard pages. The default page address is written to /etc/nginx/sites-available
.
Besides Nginx, you can install PHP for a more functional website:
sudo apt install php-fpm
Next,
/etc/nginx/sites-available
we find the line index index.html index.htm;
and add it to the middle index.php
, and in the middle of the configuration file, uncomment the following lines:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
After this procedure, we reload the configuration file.
In general, the Raspberry Pi can be used for a variety of useful DIY projects. For example, make a wall calendar, turn a USB printer into a wireless printer , set up your own VPN server, and more.
For the purpose of experiment, even the official Raspberry Pi website (and this is a large and visited site) was once hosted on Raspberry Pi 3 mini-computers , I had to build a cluster of eight pieces.
A cluster of four Raspberry Pi Model B and one Raspberry Pi Model B +, the total cost of the system is $ 183.34 (from another project )
During the day of the experiment, the cluster served tens of millions of visitors.
A home web server on a single board computer consumes very little power, and only a single solar panel on the balcony is enough for it. In September 2018, an enthusiast from Low-tech Magazine launched an experiment with such a web server on the Olimex Olinuxino A20 Lime 2 single-board device, which by now has been almost uninterruptedly working for about two years (about 95% uptime). The first prototype of a solar server with a charge controller According to the developer's calculations, the energy consumption per one unique visitor is 0.021 Wh. Simplified web server power supply diagram. It does not have a voltage converter from 12 to 5 volts and an ampere-hour meter
Blockchain and distributed hosting
A number of experimental projects have been created on the basis of the blockchain, including cryptocurrencies, smart contracts, document authentication, electronic voting and much more, including decentralized hosting. One of the first projects of this kind was Swarm from Ethereum developer Viktor Tron.
Welcome to the Swarm .... Bzzz Bzzzz Bzzzz \ / \ o ^ o / \ () / ____________ (%%%%%%%) ____________ (/ /) %%%%%%% (\ \) (___ / ___ / __ / \ __ \ ___ \ ___) (/ / (%%%%%%%) \ \) (__ / ___ / (%%%%%%%) \ ___ \ __) / () \ / (%%%%%) \ (%%%) !
Decentralized hosting assumes that the site is simultaneously stored by several network participants. In theory, this increases the site's resistance against DDoS attacks or government censorship.
Swarm software has been released for all major platforms: Linux, macOS, Windows, Raspberry Pi, Android and iOS. To raise a Swarm node, you had to download the corresponding binary from the official page or raise Swarm in a Docker container.
However, new versions for Swarm nodes have not been released since February 2020, so the network is now in question. The developers write that they have moved on to develop a new Bee client that is based on the more advanced networking layer ( libp2p). They also find it easier to rewrite the system from scratch than to fix bugs. One way or another, Swarm and Bee are interesting experiments that demonstrate the conceptual power of distributed hosting.
Another P2P project can be mentioned: image hosting ipfs.pics , based on the InterPlanetary File System . It has been working smoothly for several years now. The files are stored here on the P2P network of users. When a picture is uploaded to the network, a 46-byte hash is calculated for it, which serves as a unique file identifier. The hash matches the file name. To download a file, you just need to know its hash. For instance:
http://ipfs.pics/ipfs/QmcT99xWRNDAYunp7Zr8wGiwMKSgVfDpfbXw9hBtLCM4Mm
Files on an IPFS distributed network are nearly impossible to delete or lock. The server source code is published on Github .
To protect against garbage, the network only distributes files that someone requests for storage to new peers.
Another P2P image hosting can be organized on the Tornado framework by specifying the GridFS file system . An instruction was published on Habré on how to make such a service in 30 lines of code .
"Hosting" on other people's servers
If someone dares to open ports on their computer and look at the logs, they will immediately understand what kind of hostile environment they are in. Lots of scan attempts on all standard ports with requests for installed software. If you do not take protective measures, then you can find vulnerabilities in the software on almost any server and gain access to it with administrator rights.
Then the attacker himself chooses what to do with the resources that fell into his hands: make a deface for the sake of lulz, install a cryptocurrency miner, add to a botnet for DDoS, or place files for distribution. This is called "hosting on someone else's servers" - an illegal option used by hackers.
For example, the largest modern botnet Emotet spreads its malicious load through a network of compromised sites, which the botmaster named Ivan controls through his web shells installed there.
Several other botnets work the same way. These include home computers, Linux web servers, smartphones, routers, and other IoT devices such as Android smart TVs .
On devices from a botnet, an attacker can host his files as on a kind of distributed hosting. This is a fairly reliable storage, because many users do not update software for years, do not use a firewall, and do not monitor traffic.
In general, self-hosting has a number of advantages. The server in the basement or balcony is completely under your control. You install any hardware and software you want. Nobody needs to pay a monthly hosting fee (on the contrary, you can provide such services yourself). And the main advantage is that it is always interesting to learn something new, in this case, to master some skills of an engineer and devops.
If you need a reliable server that works like a Swiss watch, then you are welcome to VDSina ! Only modern and branded equipment, some of the best data centers in Russia and the Netherlands, DDoS protection out of the box, a convenient proprietary server control panel and many other perks. Hurry up to order!