0

I'm really confused with reverse proxy. What i understood is in forward proxy the client know the destination server but the server doesn't know the client, in reverse proxy the server knows the client but the client doesn't know the "server" he's visiting is a actually proxying to some other server. And to use the reverse proxy you can use NGINX. But if we can use that, why do express framework middlewares like http-proxy-middleware

exist?

and if my understanding of proxy and reverse proxy is wrong please correct me

1 Answer 1

1

Lets take an abstract example:
You will agree that you must be using port 3000 or something to run NodeJS... Right?
And lets say you also use angular/react or html+css to run your frontend website which is lets say on port 4200 (default for angular).

Now what if you want to have only one server and want two different services (frontend in angular and backend in nodejs) to run on that single server only.

So you need something in between your client and server to distinguish between the requests whether to forward them to angular or nodejs or any other service as well that is running on the same server.

What reverse proxy such as NGINX will do is you will define some rules on the basis of which the administrator of the server can utilize same server to serve various services.

This is the simplest example I can think of on the top of my head.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. But What i still can't understand is why npm packages like http-proxy-middleware are used. They say, they're suitable for reverse proxying. Does that mean i can replace NGINX with an nodejs server that uses their middleware?
No You can't replace NGINX with an nodejs server that uses their middleware.
But sometimes you want divert the requests before they are handled by the backend server. It is kind of the architectural design difference that you want to have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.