Nginx Basics — Part 2: Reverse Proxy
On the web there are basically two types of computers (or more accurately, computer programs). A Server, whose job it is to serve web content. This service may include things like an HTML web page, a dynamic website with user specific contents like Facebook, web apps, or even APIs which programmers can use within other web services, like "Sign In with Google" which is used authenticate users across hundreds of web services. Point is, all of this services are provided what is known as a Server. It is the job of the server to listen for new requests, and give out appropriate response for the requests. Servers are the backbone of the web.
There's another type of program, that is the client. A client sends requests to web servers and gets a response. A client can be your web browser trying to visit a particular website. It can be a Discord App on your desktop talking to Discord servers and enabling you to chat with your friends, and it can even be a command line tools like cURL. If you use Python's request module to talk to a RESTAPI, what you are writing is an HTTP client.
Proxy and Reverse Proxy
A Proxy, in the context of the World Wide Web, means another computer that acts as a client on your behalf. So, a proxy acts as a server that recieves all of the client's HTTP requests, and then it passes those requests onto whatever actual server the request was intended for. This can be used to obfuscate the true origin of the client, to filter out unintended requests in the case of a University or an Organization's network and for a lot of other purposes. A proxy can be used by one or more clients.
A reverse proxy is a proxy for one or more servers, and it acts as a gateway for all the incoming HTTP requests. It ensures that a request reaches its corresponding backend server, and not the wrong one. Of course, it also makes sure that response gets forwarded to the appropriate client as well.
Let's try and configure Nginx to act as a reverse proxy for two web apps.
by subscribing to our newsletter.
Share this post:Reddit Hacker News Facebook Twitter Flipboard
Like what you saw? Subscribe to our weekly newsletter.