Reverse Proxy Server for noobs (not Nginx / Apache!)
Tags: linux, networking, beginners, webdev
Published: 2023-06-04 03:41:43

I guess most of the web devs out there know what is a reverse proxy server. It is especially useful when you have multiple services deployed on a single homelab rack or a cluster of servers and want to expose them to the internet using a single gateway server with different subdomains. In this blog post, I will simply share my experience on why I wrote my own reverse proxy server in Go to replace apache / nginx in my distributed homelab setup.

## What is Reverse Proxy Server?
Imagine you're at a music festival, grooving to your favorite tunes, and suddenly you need a refreshing drink. You don't want to miss a beat, so you send your friend, the reverse proxy, to fetch it for you. Your friend navigates through the crowd, stands in line, and brings back that ice-cold beverage without interrupting your dance moves. In this scenario, the reverse proxy server acts as your go-between, shielding you (the user) from the chaos of the festival (the backend servers) and delivering the content you desire. 

Modern reverse proxy do more things just to relay and fetch webpage for you. For example, load balancing, failover, some managers like Nginx Proxy Manager (NPM, not the blackhole npm) even have build in automatic SSL certificates renew and so on. That is why reverse proxy is usually considered the "heart" of a homelab system (or any kind of web systems)

## Why I am writing my own Reverse Proxy Server?
If you have never experience with the pain of writing an apache or nginx config as a senior dev-ops, it is a really memorable experience. You try copy things from the internet, modify them according to your knowledge and figure out its routing is unpredictable. Sometime the routing only works in testing environment but not the productions, and many web services that depends on some special settings in rewrite rules and headers. It is just pain in the *** to make all the service running.

Besides, it is just inconvenience to ssh into your gateway server and modify the config when you just want to add a temporary rules for proxying a testing environment or systems. 

There are alternatives or solutions to these issue in the open source world. Like NPM is the one that most recommended by Redditors in r/selfhost. However, it have been outdated and it is known to break a lot of stuffs with the latest updates. That is why I decided to write my own to solve my issue in the foreseeable future. 

## That is why Zoraxy was born
{% embed https://github.com/tobychui/zoraxy %}
Zoraxy is a Go-Powered Reverse Proxy and Forwarding Tool for Web Developers

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ij8hnfey6vgqmv0kicz.png)


Looking for a versatile and user-friendly reverse proxy and forwarding tool? Look no further than Zoraxy! Built from the ground up using the power of Go, Zoraxy is a go-to solution for low-power devices and beyond. With its comprehensive set of features and straightforward interface, Zoraxy empowers both senior and casual web developers to effortlessly manage their web services and enhance their online presence.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vmyfcu7yb56syb1nu5ma.png)


Let's delve into the exciting world of Zoraxy and explore its impressive feature set. First and foremost, Zoraxy shines as a reverse proxy, allowing you to seamlessly route incoming requests to the appropriate backend servers. Whether you need subdomain reverse proxy capabilities or virtual directory reverse proxy functionality, Zoraxy has got you covered.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chukt69kuwtco9g4td4f.png)


But that's not all! Zoraxy goes above and beyond with its extensive array of features. Need to set up redirection rules? Zoraxy has you covered. 



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ra77b6e251u3xdjtjol0.png)

Looking to implement TLS/SSL for enhanced security? Zoraxy has your back there too. 



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x71wurei50801ss01qye.png)

Worried about unwanted traffic? Zoraxy offers the ability to blacklist specific countries or IP addresses, providing you with granular control over your network.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddxqp4muzz0k3q2gul2r.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m1acjw0f2csy2j7el1ly.png)


Zoraxy doesn't stop at just being a reverse proxy either. It comes packed with handy utilities like CIDR IP converters, mDNS Scanner, and IP Scanner, making your web development tasks a breeze. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fi374x9d8fyxw3xaycvb.png)


And for those times when you need remote access, Zoraxy even provides a convenient Web-SSH Terminal.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fe4tv8oxtnyg4b7gp95.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ryd0a06t391xor5mv0a1.png)


Want to know who are visiting your site? Zoraxy also got a build in statistic viewer where you can get an overview on the traffics on your site without the need of cookies (non-personalized tracking)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvaq2g1ynoprwbwuk0e5.png)



Managing Zoraxy is a breeze thanks to its simple-to-use interface and in-depth instructions built right into the system. Whether you're a seasoned developer or just starting out, Zoraxy offers a basic single-admin management mode (like a home router) that ensures a hassle-free experience. If you already got an upstream reverse proxy server with permission management set-up, you can even run Zoraxy in no-auth mode, making it integrate with your current infrastructure with ease.

## Work In Progress
As this was just open source a few weeks ago, I still got a few more functions that I wanted to add and it is working in progress. One of the most requested features are the ACME automatic certificate update. However, I am still working on the details on how ACME works. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8qm6wefurpbew6zx56q.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8lwun0zer8hm4qqrudc5.png)



Meanwhile, there are a few experimental functions that is nearly completed. Like the TCP Proxy and ZeroTier controller integrations. 

## Know More
If you are interested to learn more about this open source project, feel free to take a look at our website at
{% embed https://zoraxy.arozos.com/ %}

or our github repo over at
{% embed https://github.com/tobychui/zoraxy %}

If you like this project, please give us a star so we know there are users waiting and looking forward to this project to enter Beta phrase. Thanks for the support :)