Is setting up the home server an easy task?
Story
(You can checkout implementation here)
I love ❤️ to use open-source applications and self-host them on my server for that I have an oracle cloud free tier instance. And that was used to go down ❌ anytime whenever Oracle Cloud wants to take it down.
As it falls under the free tier instance.
But one good thing about that was it never takes down the disk attached to the machine.
So my data never goes anywhere even if they stop the machine.
One day I was wondering and my spare laptop was in front of me lying down under the table.
Because no one was using that. So I got this idea If I attach all my HDD and SSD to this laptop and make it a server. Then this might be the most powerful and cost-efficient server.
I started doing research about how a server works and so many other things.
In order to make your server work properly you required these things.
- Any kind of pc/laptop 💻/mobile📱/tablet which is alive.
- Always connected to the consistent internet 🌐.
- Requires 24x7 power if not then battery🔋 should be stable enough to power it.
- Static IP (This can be bypassed and I already told above using VPN)
- Space 💿 according to your need.
It took me around more than 1 month to set up this and make it work.
I asked so many questions to so many people and also required their assistance from time to time. In order to motivate me. And also for the confirmation that what I am trying to do is feasible enough to set up?
Another question comes into the picture here. Which method I was trying to set up my home server and why I was thinking that it is not possible?
I was using Outline VPN which I have hosted on my server. And whenever I used to get connected through my server I was used to seeing my server ip into my mobile as well. That sounds so childish thing, right? But the main idea came from here only.
I asked one of my seniors. If I am able to see my mobile ip the same as my server IP.
Does it mean I can ssh through my server to my phone?
He said yes but that totally depends on the VPN service you are using. And also allows you to connect to other devices which are on the same network. Then I did some research and found.
When we connect through any VPN service we get connected with VPN provider network. And all our traffic goes through their servers. So from here, I got this idea that I can self-host a VPN and will get into the same network as my server and all my local traffic will pass through my server.
Here is a very basic diagram from the previous blog to understand this in detail.
But if everything starts working the way you think then things might get much sorter for you.
To achieve this I self-hosted outline VPN to my server which was with very low specifications. As I already self-hosted it once. So it was very easy for me to self-host again. Here you can learn how to self-host outline VPN.
Till now I was thinking that everything will going to work as I was thinking and was working as well. Outline VPN started working and I was able to connect my devices. But the issue was I was not able to tunnel my traffic (which means I was not able to do port forwarding) through outline VPN and that was the major hurdle even after connecting my device with the same network.
I did research for around a week about why this setup is not working and how to overcome this issue. But after trying even all the ways I was not able to solve this issue.
The reason could be a lack of experience. As I started learning system administration just a couple of months ago. I am a beginner and stuck with so many issues. But love not to leave anything undone. And try to complete whatever I start.
So you might be thinking what was the issue with this setup right?
Think! Think! And keep thinking.
The issue was docker. As I did all setup using the docker image provided by outline VPN. In the starting phase, I was unaware of how all the outline thing was working. But after some research and spending time digging up with outline VPNsetup. Now I can explain so when I was connecting my device to outline VPN. First, it was going to my server then it was routing it to the internal IP of docker. And then re-routing to outline vpn internally. And the issue was here only.
I left everything with outline VPN here only rather than spending more time. I started searching for alternative ways to implement this setup and other self-hosted VPNs.
Searching this much was to go with some already configured service. Because that would be less time-consuming. And easy for me to configure.
But I like to take challenges and prove myself wrong that taking shortcuts is not always should be the way. So as always this time also I preferred to do more research and got to know about Wireguard VPN.
You can read my blog on how to self-host wireguard.
The benefit of using wireguard here are
- More secure network.
- Encrypted tunnels.
- Peers to Peers connection.
- Access all the other peers over the same network.
Apart from all the other points my main focus was to have point 4. Which I was not able to achieve with outline VPN.
You might be able to achieve this with Outline VPN as well.
But...
You might be thinking this is the end of the story. But no it is just starting.
I started self-hosting wireguard vpn around 9 pm. And didn't get to know when time passed and it was 4:55 in the morning when I finally decided to go to sleep.
Tried for almost 2 days till the same time.
But didn't get any success. I was not able to figure out the issue anyway.
I was able to connect the VPN client with the VPN server but the internet was not working over VPN.
I decided to leave everything there only. Because all this was so frustrating.
And took 1 day of rest. Then again started self-hosting Wireguard VPN.
- Took help from so many people.
- Asked Chat GPT.
- Followed so many blogs.
But nothing was working and day by day I was losing hope.
I started thinking that I have chosen the wrong way to set up this. But this happens always with me or with everyone I think.
When you actually start losing hope. That is the point when you start getting some other hope.
So I decided to try the last time. After this final try, I will leave this project in between. And will continue later on after some time.
Luckily at 3:47 am. I got this GitHub repository. I decided to try last time.
And I did everything as it was written in the readme.md file.
But again when I tried to connect the Windows client to the VPN server.
I was not able to connect to the internet. After checking all the configuration files. I found this time ip was incorrect in configuration. So I changed it.
And tried reconnecting with the VPN client.
But I think issues started falling in love with me. And again it didn't work out.
I decided to shut down my laptop
But in my mind. I was not able to accept that why is it not working. So went back and started the laptop again.
Opened the terminal did ssh to my server cross checked everything.
Came back to the Windows client and started VPN. Checked configuration. I changed the IP range and suddenly everything started working. I was like.. is this reality that it started working? I was not able to believe that it took around 2 weeks or even more, I think to get this work done.
I went back to the server again did ssh and started setup for reverse proxy. I was literally so excited to see the Nginx page of my home laptop through a domain name.
And finally after setting up everything.
It was million dollar happiness for me at that time
But guess what?
I didn't expect that million-dollar happiness will only be for milliseconds😥.
Don't you want to know why?
The next, day I installed an Ubuntu server distro on my home laptop to make it work as a proper server. Installed nginx and other services which are necessary to make my setup work.
But unfortunately or fortunately 🔮 I don't know why this happens to me only.
I installed wireguard client on Ubuntu server. I was so happy and did it the way it should be done. But again I was not able to connect through the Ubuntu server (home server) VPN client to the VPN server.
But this time it was working with a Windows client so there was no issue with the VPN server that was for sure.
Again
- Asked so many people
- Tried so many blogs
- Asked Chat GPT and Google
- Followed stackoverflow
But nothing worked out. Because the issue was very unique as always.
I was able to run wireguard client in all the non-server distributions of Ubuntu or Debian. But not with the server-based distribution. The reason might be some firewall issue. But I completely disabled the firewall. Still, nothing worked out.
So much tired for around 2 weeks on this as well. Then consulted finally with a few people from tech communities. And I was not in the mood for re-installing the Ubuntu desktop.
But unfortunately, I need to do to overcome this issue.
After installing and setting up the Ubuntu desktop with a VPN client here are a few messages I did to someone.
That was only the final solution available at that time. But sometime I will try to figure it out. What was the reason why wireguard client was not working with Ubuntu server-based distribution? What was causing this issue? If anyone who is reading this blog knows what could be the reason or went wrong let me know in the comment section.
Wait the story doesn't end here...
Another issue was waiting for me to welcome.
When everything started working fine.
The VPN client was getting disconnected from the VPN server after a span of time.
I was thinking this could be the issue of laptop configuration it might be forcing to disconnect through the internet after a span of time. Or putting my laptop on sleep.
I configured everything so that the laptop doesn't go to sleep.
Doesn't disconnect from the internet.
But the issue still persisted....
I was like what the hell is this...
But as we Indians are good at doing Jugaad.
I did the same.
Started juggling and researching what can be the reason. Nothing didn't work out.
Then dimaag ki batti jali... or ek idea aaya.. (दिमाग की बत्ती जाली... और एक आइडिया आया)
I wrote a cron job that does ping-pong to the VPN server after the span of every 3 minutes.
This time I took the help of Chat GPT to get these 3 lines of bash script.
You won't believe this was the final issue that came till now with the VPN server and client.
I was not able to believe that this started working as I expected.
I tried hosting a few applications like password manager, and a few local servers tested running through the web.
I was so happy at the end after achieving all this.
Don't forget to check out the implementation part.
Thanks for reading and if you find this interesting can share it with others.
Wait..
As we all know writing these kinds of useful blogs/stories for you all takes so much effort, research, and time. So if you want to support me in any way that would be helpful for me. (Optional)
Here are a few ways you can support me.
- Share this blog on your social handles like - Twitter, Instagram, or LinkedIn.
- Subscribing to our newsletter.
- Suggest new ideas for creating blogs.
- Help in debugging issues.
- Support me using UPI. Paying any amount you want. That can help me purchase hardware required for new projects and do research - orendrasingh@dbs
- Or buy me a coffee - https://bmc.link/orendrasingh