Both sides previous revisionPrevious revisionNext revision | Previous revision |
guides:self-hosting_guide [2025/02/21 14:14] – wgp | guides:self-hosting_guide [2025/02/23 11:45] (current) – wgp |
---|
* [[https://github.com/hintjen/selfhosted-gateway|Self-hosted Gateway]] - A self-hosted VPS solution | * [[https://github.com/hintjen/selfhosted-gateway|Self-hosted Gateway]] - A self-hosted VPS solution |
* [[https://www.wireguard.com/|WireGuard]] (or [[https://tailscale.com/|Tailscale]], a proprietary alternative based on WireGuard, or [[https://netbird.io/|Netbird]]) - A VPN like WireGuard does not solve the problem by itself, but more on that later. | * [[https://www.wireguard.com/|WireGuard]] (or [[https://tailscale.com/|Tailscale]], a proprietary alternative based on WireGuard, or [[https://netbird.io/|Netbird]]) - A VPN like WireGuard does not solve the problem by itself, but more on that later. |
| |
| {{:guides:self-hosting_flowchart.jpg?nolink|}} |
| |
At Well Gedacht Publishing, we also had this issue with the ISP sharing an IP address with multiple households, and were able to get a dedicated IP—yet a dynamic one—after calling their customer service. Currently, our self-hosted websites and services run on our home server, without any VPS or another type of solution to the dynamic IP address problem. This means that once our ISP decides to change our IP address, for example if we restart our router, or the electricity goes out etc, our IP address changes too, and in that case, we would need to update the DNS records on our registrars ourselves; also meaning that our websites will be inaccessible, if we don't update the IP address on the DNS records, which is something we are OK with. Every once in a while, your websites might have some downtime, and if you are OK with this, you can even self-host with your dynamic IP address. There are also tools for monitoring the uptime of your sites, like [[https://github.com/louislam/uptime-kuma|this one]]. | At Well Gedacht Publishing, we also had this issue with the ISP sharing an IP address with multiple households, and were able to get a dedicated IP—yet a dynamic one—after calling their customer service. Currently, our self-hosted websites and services run on our home server, without any VPS or another type of solution to the dynamic IP address problem. This means that once our ISP decides to change our IP address, for example if we restart our router, or the electricity goes out etc, our IP address changes too, and in that case, we would need to update the DNS records on our registrars ourselves; also meaning that our websites will be inaccessible, if we don't update the IP address on the DNS records, which is something we are OK with. Every once in a while, your websites might have some downtime, and if you are OK with this, you can even self-host with your dynamic IP address. There are also tools for monitoring the uptime of your sites, like [[https://github.com/louislam/uptime-kuma|this one]]. |
</code> | </code> |
- //Optional step//: You can run Docker on the terminal, but if you prefer to have a GUI to manage your Docker containers, you can install [[https://www.portainer.io/|Portainer]]. For deploying the Portainer as a Docker container, you can: <code> sudo docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce:latest </code> | - //Optional step//: You can run Docker on the terminal, but if you prefer to have a GUI to manage your Docker containers, you can install [[https://www.portainer.io/|Portainer]]. For deploying the Portainer as a Docker container, you can: <code> sudo docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce:latest </code> |
- Next step is to deploy the Nginx web server container. For that, we simply type: <code> sudo docker run -it --rm -d -p 8080:80 --name web -v ~/site-content:/usr/share/nginx/html nginx </code> This command tells this Nginx container to listen for upcoming traffic on the port 8080, and the content of your website, such as the index.html goes to the directory ~/site-content, and the name of the container is "web." | - Create a directory where you will place the index.html file, named site-content: <code> mkdir ~/site-content </code> |
| - Next step is to deploy the Nginx web server container. For that, we simply type: <code> sudo docker run -it --restart always -d -p 8080:80 --name web -v ~/site-content:/usr/share/nginx/html nginx </code> This command tells this Nginx container to listen for upcoming traffic on the port 8080, and the content of your website, such as the index.html goes to the directory ~/site-content, and the name of the container is "web." You can check if Nginx is succesfully deployed and running by typing your-computer's-IP-address:8080 on your brower, and it will show you this page: {{ :guides:install_nginx_welcome.png?nolink&400 |}} |
- Now, we need to deploy the Nginx Proxy Manager container, which is a very nice reverse proxy manager. With it you can expose the ports 80 and 443 of your router to outside traffic, and then direct the incoming traffic to the web server you deployed in the previous step. It also helps you with getting SSL encryption certificates with Let's Encrypt and use https on your website very easily. First, create a new directory called npm: <code>mkdir -p npm | - Now, we need to deploy the Nginx Proxy Manager container, which is a very nice reverse proxy manager. With it you can expose the ports 80 and 443 of your router to outside traffic, and then direct the incoming traffic to the web server you deployed in the previous step. It also helps you with getting SSL encryption certificates with Let's Encrypt and use https on your website very easily. First, create a new directory called npm: <code>mkdir -p npm |
cd npm</code> Then, create a Docker compose file there: <code># Create a docker-compose configuration file | cd npm</code> Then, create a Docker compose file there: <code># Create a docker-compose configuration file |
- ./data:/data | - ./data:/data |
- ./letsencrypt:/etc/letsencrypt </code> Finally, you need to run: <code>docker compose up -d </code> Now, your Nginx Proxy Manager admin UI should be accessible at your Linux PC's IP address on your local network, on port 81 (something like 192.168.186.10:81). | - ./letsencrypt:/etc/letsencrypt </code> Finally, you need to run: <code>docker compose up -d </code> Now, your Nginx Proxy Manager admin UI should be accessible at your Linux PC's IP address on your local network, on port 81 (something like 192.168.186.10:81). |
- With this step, you have all the things ready for self-hosting your website. Now, **important thing** to do is, logging into your router's admin panel, and opening up the ports 443 and 80 (port 80 for HTTP and 443 for HTTPS traffic) to the internet. You do this by editing the **port forwarding** settings on your router, please check your router's instructions online, for how to do this. You need to direct incoming traffic from port 80 to your-pc's-ip-address:80 and port 443 to your-pc's-ip-address:443. In this way, Nginx Proxy Manager will start to listen incoming traffic on these ports, and will direct the traffic to our Nginx web server we set up on step 5. | - With this step, you have all the things ready for self-hosting your website. Now, **important thing** to do is, logging into your router's admin panel, and opening up the ports 443 and 80 (port 80 for HTTP and 443 for HTTPS traffic) to the internet. You do this by editing the **port forwarding** settings on your router, please check your router's instructions online, for how to do this. You need to direct incoming traffic from port 80 to your-pc's-ip-address:80 and port 443 to your-pc's-ip-address:443. In this way, Nginx Proxy Manager will start to listen incoming traffic on these ports, and will direct the traffic to our Nginx web server we set up on step 5. |
| - Copy your static website's index.html file into the Nginx web server's public www directory, which we determined as ~/site-content. |
| - Now go to your domain registrar's website, login, and add an A record for your domain. This A record should direct traffic to your public IPv4 address, which you looked up on a what-is-my-IP-type-of-website earlier. |
| - All you need to do know is to direct the incoming traffic via Nginx Proxy Manager to your-computer's-local-IP-address:8080. In order to do that go to Nginx Proxy Manager admin UI on your-computer's-local-IP-address:81, go to Proxy Hosts tab, click on Add Proxy Host on top right corner. Enter your domain name, and beneath that enter your-computer's-local-IP-address and the port 8080. Keep the scheme http. Enable "block common exploits." Go to the SSL tab on the same window, and click on "request a new SSL certificate." You can enable all of the options below (but beware; some options might make your website unreachable, so try out by disabling and enabling them). Enter your email address for Let's Encrypt, accept the ToS, and click on save. Now your website should be reachable on your domain! 🌐 |
| |
| ===Solving the dynamic IP issue=== |
| Here I will document my solution to dynamically update the //dynamic// IP address on the DNS records of my domain. Using something like [[https://github.com/jbbodart/gandi-livedns|this]]. Coming up soon! FIXME |
| |
| --- //[[[email protected]|Well Gedacht Publishing]] 2025/02/21 14:40// |
| |
---- | ---- |