Forward proxy vs reverse proxy difference explained - Brain Bytes (Java Brains)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so the first time i encountered the word proxy in my life was during my college days the word proxy was used in association with attendance someone didn't want to attend a class you set up a friend as an attendance proxy so when the lecturer calls out your name during attendance role call this friend response and you're marked as present okay that's the proxy when i was in college now you tend to hear these two terms a lot in software you have proxy you can have reverse proxy especially when you're working with back-end systems proxy servers and reverse proxy servers are they the same if not what are they what are they different in this video i will break this down and give you a very clear idea with examples of what proxy is what reverse proxy is and how they are different and you'll realize the concept of proxy is not too far removed from this idea of proxy attendance in college and you're trying to trick the lecturer and reverse proxy is where the lecturer is trying to trick you well kind of let me explain so there's one important thing that underlines all this discussion about proxies in reverse proxy it is the direction of data transfer okay direction of information exchange you first need to understand who's sending the data or information and to whom what is the source and what is the destination who's the client and who's the server once you've identified that both proxy and reverse proxy is pretty much the same thing except in different directions okay so let's first understand proxy and then we can pretty much reverse it and you will understand reverse proxy okay so the oxford english dictionary definition of proxy is a person authorized to act on the behalf of another you have proxy voting right where someone votes on behalf of another person or even proxy attendance example we've seen where your friend answers the roll call there are a couple of places in a typical web application flow where having a proxy makes sense and is very common so you type in the url and you hit enter let's say you want to enter java brainstorm i on your browser and submit your request doesn't directly go to the website there's your internet service provider for example sitting in between you and the website who takes your request and then sends another request to the website of course there could be multiple other steps as well in between but assuming the simple picture your internet service provider or isp is acting as a proxy for you okay it's sending a request on your behalf and that's really what a proxy is another common example of proxy is found in workplaces some workplaces block certain websites right offices block certain websites and they monitor websites that employees use well how do they do that well they certainly cannot do that if the employee is allowed to make a request to a website directly no they need to get in the middle and they do this by using a proxy when an employee requests a website they're actually talking to this proxy and the proxy then makes sure that this isn't some unsafe or pornographic website and then it makes the request on behalf of you here's how a proxy typically looks like you have multiple clients behind a proxy server these are typically multiple computers in one network a typical office network would look something like this a proxy receives requests from many clients but then it makes requests to wherever the request actually needs to go and then it waits for the corresponding responses and then sends the right responses to the right clients who initiated those corresponding requests so why do we do this there are a couple of advantages in having a proxy first like we've seen a proxy can intercept your request and decide not to pass the request along in the case of blocked websites you can also choose to log or monitor requests it's easy for organizations to enforce these restrictions and security in one place which is the proxy rather than on each individual employee's computer another advantage is that the proxy can cache requests instead of passing it through each time let's say there is a certain static page that's accessed by multiple people and close to each other in terms of request times the proxy can make just one request and then cache it when there are subsequent calls to the same page the proxy will just return the cached response rather than make a new request again but overall the most important thing that you should remember about a proxy is that the server or the receiver doesn't know where the request is coming from or who the client is because of this kind of a decoy or a proxy now you might wonder well how does this work with authenticated pages so let's say you've logged into google mail okay and you make this request as yourself and it goes to the proxy now the proxy is making a request to gmail servers on your behalf well then when google gets the proxy's request how does it know it's you and send the response with your inbox contents well it's very simple what a proxy does is actually take your request as is and make the exact same request from itself okay so now if this request is authenticated it might contain cookies or jwts or something else which identifies this authenticated session so in that sense the server kind of knows what the request is but not where the request is coming from okay i hope that makes sense so this is proxy and it's often referred to as forward proxy okay in contrast to this is another concept called reverse proxy as you can imagine this is a reverse concept while forward proxy is meant to proxy requests going out or forward a reverse proxy is meant to proxy requests coming in what kind of things have requests coming in yep they're servers okay so if forward proxies are for clients reverse proxies are for servers imagine we have hosted an application on like a handful of servers they could be micro services with different end points on these servers or there could be multiple scaled copies of the same application now rather than have the client be aware of the nuances of how you have set up your servers you set up a proxy server in front of these servers this proxy is responsible for getting requests from the outside world and then make the right request to the right server get the response and then send that response to the right client the principle is kind of the same in this case the client doesn't know what the actual server is that's handling the request this is proxy but in the reverse direction hence called reverse proxy so what are the advantages of reverse proxy well security is an advantage again when you host your application and start accepting requests you can set up a reverse proxy that manages the security of your application you can protect against denial of service attacks you can do rate limiting you can set up a firewall and you can stop hackers bots or other malicious requests and since your actual server ips are hidden from the client it makes your infrastructure a little more secure another advantage is caching you can cache certain responses so that when the request comes in you can send the response back without even bothering the server with it however one very common use of reverse proxy is load balancing when you have a scale application server that is you can start up multiple instances of your same app server and depending on the load you can increase or decrease the number of instances you would want this incoming traffic to be evenly distributed across these server instances and this is a great use for the reverse proxy as a load balancer this load balancer reverse proxy can use a strategy like round robin to evenly distribute requests to the available servers and the clients have no idea about it just like it should be so now you know the difference between forward proxy and reverse proxy and you also know that load balancer is a specific use case of the reverse proxy one common pattern of using reverse proxy at least in the case of microservices in the context of microservices is as an api gateway let's go check out this video to learn what an api gateway is all [Music] about [Music] you
Info
Channel: Java Brains
Views: 104,674
Rating: undefined out of 5
Keywords: java, java brains, tutorial, brains, koushik, kaushik, brainbytes, explained, programming, koushik kothagal, beginner, microservice, api gateway, microservice architecture, monolith, microservices, architecture, java tutorial, microservice tutorial, brain bytes, proxy, reverse proxy, forward proxy, load balancer
Id: AuINJdBPf8I
Channel Id: undefined
Length: 8min 47sec (527 seconds)
Published: Fri Dec 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.