Forward and Reverse Proxies
Think of a hotel front desk. A guest who wants a taxi asks the desk, and the desk calls the taxi. A caller who wants a guest also goes through the desk. Both times, someone stands in the middle. A proxy is that person for network traffic. The difference is who the desk works for.
6 min read6 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 5 sources5টি সোর্স · updated Nov 2026আপডেট: Nov 2026
A reverse proxy hides and healsরিভার্স প্রক্সি লুকায় আর সামলে নেয়
Send a student request through a reverse proxy, then hang app server 1 and see what the student gets.একটা স্টুডেন্টের অনুরোধ রিভার্স প্রক্সির ভেতর দিয়ে পাঠান, তারপর অ্যাপ সার্ভার 1 হ্যাং করান আর দেখুন স্টুডেন্ট কী পায়।
You’ll learnআপনি শিখবেন
- What a reverse proxy doesরিভার্স প্রক্সি কী করে
- Why the server needs X-Forwarded-Forসার্ভারের কেন X-Forwarded-For লাগে
- How a cache spares the serversক্যাশ কীভাবে সার্ভারকে বাঁচায়
- When a student sees 504 or no errorকখন স্টুডেন্ট 504 দেখে আর কখন এরর দেখে না
In plain words
A proxy is a program that sits between two sides of a request and passes the request on. It can be on the user's own computer, or anywhere between the user and the destination server Source 2সোর্স 2. A proxy intercepts requests and gives back responses. It may forward a request, or not (a cache can answer by itself). It may also change the request, for example its headers Source 2সোর্স 2.
There are two main kinds Source 2সোর্স 2:
- A forward proxy handles requests from clients to servers anywhere on the Internet. The client chooses it, usually through local settings Source 1সোর্স 1. An organization can use one to apply security checks, add notes to requests, or share a cache Source 1সোর্স 1.
- A reverse proxy takes requests from the Internet and forwards them to servers in an internal network Source 2সোর্স 2. The HTTP standard calls it a gateway. To the client it looks like the real server, but it passes each request to other servers behind it Source 1সোর্স 1.
Forward proxy (works for the client):
[Client] --> [Forward proxy] --> [Any website]
Reverse proxy (works for the server side):
[Client] --> [Reverse proxy] --> [App server 1]
\--> [App server 2]A tunnel is a different thing. It is a blind relay that does not change the messages. For example, it can carry encrypted TLS traffic through a firewall proxy Source 1সোর্স 1.
সহজ English
A proxy is a program that sits between two sides of a request and passes the request on. It can be on the computer of the user, or anywhere between the user and the destination server Source 2সোর্স 2. A proxy intercepts requests and gives back responses. It may forward a request, or not (a cache can answer by itself). It may also change the request, for example its headers Source 2সোর্স 2.
There are two main kinds Source 2সোর্স 2:
- A forward proxy handles requests from clients to servers anywhere on the Internet. The client chooses it, usually through local settings Source 1সোর্স 1. An organization can use one to apply security checks, add notes to requests, or share a cache Source 1সোর্স 1.
- A reverse proxy takes requests from the Internet and forwards them to servers in an internal network Source 2সোর্স 2. The HTTP standard calls it a gateway. To the client it looks like the real server. But it passes each request to other servers behind it Source 1সোর্স 1.
The path of a request:
- Forward proxy (works for the client): Client, then forward proxy, then any website.
- Reverse proxy (works for the server side): Client, then reverse proxy, then app server 1 or app server 2.
A tunnel is a different thing. It is a blind relay that does not change the messages. For example, it can carry encrypted TLS traffic through a firewall proxy Source 1সোর্স 1.
বাংলা ব্যাখ্যা
একটি প্রক্সি (proxy) হলো একটি প্রোগ্রাম, যা একটি রিকুয়েস্টের দুই পক্ষের মাঝখানে বসে এবং রিকুয়েস্ট এগিয়ে দেয়। এটি ইউজারের কম্পিউটারে থাকতে পারে, বা ইউজার ও গন্তব্য সার্ভারের মাঝে যেকোনো জায়গায় Source 2সোর্স 2। প্রক্সি রিকুয়েস্ট ধরে এবং রেসপন্স ফেরত দেয়। সে রিকুয়েস্ট ফরওয়ার্ড করতে পারে, বা নাও করতে পারে (একটি ক্যাশ নিজেই উত্তর দিতে পারে)। সে রিকুয়েস্ট বদলাতেও পারে, যেমন তার হেডার Source 2সোর্স 2।
প্রধান দুই ধরন আছে Source 2সোর্স 2:
- একটি ফরওয়ার্ড প্রক্সি (forward proxy) ইন্টারনেটের যেকোনো জায়গার সার্ভারের দিকে ক্লায়েন্টদের রিকুয়েস্ট সামলায়। ক্লায়েন্ট তাকে বেছে নেয়, সাধারণত লোকাল সেটিং দিয়ে Source 1সোর্স 1। একটি প্রতিষ্ঠান সিকিউরিটি চেক চালাতে, রিকুয়েস্টে নোট যোগ করতে বা ক্যাশ ভাগ করতে একটি ব্যবহার করতে পারে Source 1সোর্স 1।
- একটি রিভার্স প্রক্সি (reverse proxy) ইন্টারনেট থেকে রিকুয়েস্ট নেয় এবং তা একটি অভ্যন্তরীণ নেটওয়ার্কের সার্ভারে ফরওয়ার্ড করে Source 2সোর্স 2। HTTP স্ট্যান্ডার্ড তাকে গেটওয়ে (gateway) বলে। ক্লায়েন্টের কাছে সে আসল সার্ভারের মতো দেখায়। কিন্তু সে প্রতিটি রিকুয়েস্ট তার পেছনের অন্য সার্ভারে পাঠায় Source 1সোর্স 1।
একটি রিকুয়েস্টের পথ:
- ফরওয়ার্ড প্রক্সি (ক্লায়েন্টের হয়ে কাজ করে): ক্লায়েন্ট, তারপর ফরওয়ার্ড প্রক্সি, তারপর যেকোনো ওয়েবসাইট।
- রিভার্স প্রক্সি (সার্ভার দিকের হয়ে কাজ করে): ক্লায়েন্ট, তারপর রিভার্স প্রক্সি, তারপর অ্যাপ সার্ভার 1 বা অ্যাপ সার্ভার 2।
একটি টানেল (tunnel) আলাদা জিনিস। এটি একটি অন্ধ রিলে, যে মেসেজ বদলায় না। যেমন, সে একটি ফায়ারওয়াল প্রক্সি দিয়ে এনক্রিপ্টেড TLS ট্রাফিক বহন করতে পারে Source 1সোর্স 1।
When you need it
You use a reverse proxy in front of a web app for these jobs:
- Spread the load across several servers Source 5সোর্স 5 Source 1সোর্স 1.
- Pass requests to application servers, or show content from different sites under one address Source 5সোর্স 5.
- Hide old or untrusted services behind one safe front door Source 1সোর্স 1.
- Cache answers so the app servers do less work Source 1সোর্স 1.
You use a forward proxy when the client side needs control, for example when a company sends all staff web traffic through one checkpoint Source 1সোর্স 1.
সহজ English
You use a reverse proxy in front of a web app for these jobs:
- Spread the load across several servers Source 5সোর্স 5 Source 1সোর্স 1.
- Pass requests to application servers. Or show content from different sites under one address Source 5সোর্স 5.
- Hide old or untrusted services behind one safe front door Source 1সোর্স 1.
- Cache answers so the app servers do less work Source 1সোর্স 1.
You use a forward proxy when the client side needs control. For example, a company sends all staff web traffic through one checkpoint Source 1সোর্স 1.
বাংলা ব্যাখ্যা
একটি ওয়েব অ্যাপের সামনে আপনি এই কাজগুলোর জন্য রিভার্স প্রক্সি ব্যবহার করেন:
- লোড ছড়িয়ে দেওয়া, কয়েকটি সার্ভারের মধ্যে Source 5সোর্স 5 Source 1সোর্স 1।
- রিকুয়েস্ট অ্যাপ্লিকেশন সার্ভারে পাঠানো। অথবা বিভিন্ন সাইটের কনটেন্ট একটি অ্যাড্রেসের নিচে দেখানো Source 5সোর্স 5।
- পুরোনো বা অবিশ্বস্ত সার্ভিস লুকিয়ে রাখা, একটি নিরাপদ সদর দরজার পেছনে Source 1সোর্স 1।
- ক্যাশ (cache) করা, যাতে অ্যাপ সার্ভারকে কম কাজ করতে হয় Source 1সোর্স 1।
ক্লায়েন্ট দিকের নিয়ন্ত্রণ দরকার হলে আপনি ফরওয়ার্ড প্রক্সি ব্যবহার করেন। যেমন, একটি কোম্পানি সব কর্মীর ওয়েব ট্রাফিক একটি চেকপয়েন্ট দিয়ে পাঠায় Source 1সোর্স 1।
How it works
Request flow. NGINX sends the request to the proxied server, fetches the response, and sends the response back to the client Source 5সোর্স 5. In its configuration, the proxy_pass directive inside a location block names the server that gets the request Source 5সোর্স 5.
Default behavior. By default, NGINX changes two headers of the proxied request, Host and Connection. The proxy_set_header directive changes this Source 5সোর্স 5. By default NGINX also buffers the response. It keeps the whole response and sends it to the client only after it has received all of it Source 5সোর্স 5.
Client address. The server behind the proxy has a problem: it sees only the address of the last proxy, not the address of the user Source 4সোর্স 4. To fix this, the proxy adds the client address in a header. The common header is X-Forwarded-For. It is a de-facto standard, not a formal one Source 4সোর্স 4. The standard version is Forwarded, with the parts by, for, host, and proto Source 3সোর্স 3. Forwarded also keeps the original Host header and the protocol the client used Source 3সোর্স 3.
X-Forwarded-For: 203.0.113.195, 198.51.100.17
^ client ^ most recent proxyThe leftmost address is the client and the rightmost is the most recent proxy, if every party is well behaved Source 4সোর্স 4. The Via header is another trace. It shows which proxies a message passed, and it helps to avoid request loops Source 1সোর্স 1.
সহজ English
NGINX sends the request to the proxied server. It fetches the response, and sends the response back to the client Source 5সোর্স 5. In its configuration, the proxy_pass directive inside a location block names the server that gets the request Source 5সোর্স 5.
By default, NGINX changes two headers of the proxied request, Host and Connection. The proxy_set_header directive changes this Source 5সোর্স 5. By default NGINX also buffers the response. It keeps the whole response and sends it to the client only after it has received all of it Source 5সোর্স 5.
The server behind the proxy has a problem. It sees only the address of the last proxy, not the address of the user Source 4সোর্স 4. To fix this, the proxy adds the client address in a header. The common header is X-Forwarded-For. It is a de-facto standard, not a formal one Source 4সোর্স 4. The standard version is Forwarded, with the parts by, for, host, and proto Source 3সোর্স 3. Forwarded also keeps the original Host header and the protocol the client used Source 3সোর্স 3.
For example, X-Forwarded-For: 203.0.113.195, 198.51.100.17. The leftmost address is the client. The rightmost is the most recent proxy. This holds if every party is well behaved Source 4সোর্স 4. The Via header is another trace. It shows which proxies a message passed, and it helps to avoid request loops Source 1সোর্স 1.
বাংলা ব্যাখ্যা
NGINX রিকুয়েস্টটি প্রক্সি করা সার্ভারকে পাঠায়। সে রেসপন্স আনে এবং রেসপন্স ক্লায়েন্টকে ফেরত পাঠায় Source 5সোর্স 5। এর কনফিগারেশনে একটি location ব্লকের ভেতরের proxy_pass ডিরেক্টিভ বলে কোন সার্ভার রিকুয়েস্ট পাবে Source 5সোর্স 5।
ডিফল্টভাবে NGINX প্রক্সি করা রিকুয়েস্টের দুটি হেডার বদলায়, Host ও Connection। proxy_set_header ডিরেক্টিভ এটি বদলায় Source 5সোর্স 5। ডিফল্টভাবে NGINX রেসপন্স বাফারও করে। সে পুরো রেসপন্স নিজের কাছে রাখে এবং সব পাওয়ার পরই ক্লায়েন্টকে পাঠায় Source 5সোর্স 5।
প্রক্সির পেছনের সার্ভারের একটি সমস্যা আছে। সে শুধু শেষ প্রক্সির অ্যাড্রেস দেখে, ইউজারের অ্যাড্রেস দেখে না Source 4সোর্স 4। এটি ঠিক করতে প্রক্সি একটি হেডারে ক্লায়েন্টের অ্যাড্রেস যোগ করে। সাধারণ হেডার হলো X-Forwarded-For। এটি একটি ডি-ফ্যাক্টো স্ট্যান্ডার্ড (de-facto standard), আনুষ্ঠানিক নয় Source 4সোর্স 4। স্ট্যান্ডার্ড রূপ হলো Forwarded, যার অংশ by, for, host ও proto Source 3সোর্স 3। Forwarded আসল Host হেডার এবং ক্লায়েন্ট যে প্রোটোকল ব্যবহার করেছিল, তাও রাখে Source 3সোর্স 3।
উদাহরণ: X-Forwarded-For: 203.0.113.195, 198.51.100.17। সবচেয়ে বাঁয়ের অ্যাড্রেস হলো ক্লায়েন্ট। সবচেয়ে ডানের হলো সাম্প্রতিকতম প্রক্সি। এটি খাটে যদি প্রতিটি পক্ষ নিয়ম মেনে চলে Source 4সোর্স 4। Via হেডার আরেকটি চিহ্ন। সে দেখায় একটি মেসেজ কোন কোন প্রক্সি পার হয়েছে, এবং এটি রিকুয়েস্ট লুপ এড়াতে সাহায্য করে Source 1সোর্স 1।
A real-life example
An online learning platform has two app servers behind one reverse proxy. A student opens the course page. The proxy receives the request, picks an app server, and returns the answer. The student never sees the two servers. One day the first app server hangs. The proxy waits and then returns a 504 Gateway Timeout, which means it got no timely answer from the server behind it Source 1সোর্স 1. Another day the app server sends a broken answer, and the proxy returns 502 Bad Gateway, which means it got an invalid response Source 1সোর্স 1.
সহজ English
An online learning platform has two app servers behind one reverse proxy. A student opens the course page. The proxy receives the request, picks an app server, and returns the answer. The student never sees the two servers. One day the first app server hangs. The proxy waits and then returns a 504 Gateway Timeout. It means the proxy got no timely answer from the server behind it Source 1সোর্স 1. Another day the app server sends a broken answer. The proxy returns 502 Bad Gateway. It means the proxy got an invalid response Source 1সোর্স 1.
বাংলা ব্যাখ্যা
একটি অনলাইন লার্নিং প্ল্যাটফর্মে একটি রিভার্স প্রক্সির পেছনে দুটি অ্যাপ সার্ভার আছে। একজন স্টুডেন্ট কোর্স পেজ খোলে। প্রক্সি রিকুয়েস্ট পায়, একটি অ্যাপ সার্ভার বেছে নেয় এবং উত্তর ফেরত দেয়। স্টুডেন্ট কখনো দুটি সার্ভার দেখে না। একদিন প্রথম অ্যাপ সার্ভার হ্যাং করে। প্রক্সি অপেক্ষা করে এবং তারপর একটি 504 Gateway Timeout ফেরত দেয়। এর মানে প্রক্সি তার পেছনের সার্ভার থেকে সময়মতো উত্তর পায়নি Source 1সোর্স 1। আরেকদিন অ্যাপ সার্ভার একটি ভাঙা উত্তর পাঠায়। প্রক্সি 502 Bad Gateway ফেরত দেয়। এর মানে প্রক্সি একটি অবৈধ রেসপন্স পেয়েছে Source 1সোর্স 1।
Common mistakes
- Trusting
X-Forwarded-Forfor security. Anyone can send this header. Only addresses added by a trusted proxy are safe for rate limiting or IP-based access control. Other parts of the header may be spoofed Source 4সোর্স 4. - Leaving the app server open to the Internet. If the server can be reached directly, no part of the list is trustworthy, even when a trusted reverse proxy is also in front of it Source 4সোর্স 4.
- Reading only one of several headers. Using only one
X-Forwarded-Forheader is not enough Source 4সোর্স 4. - Forgetting the privacy side. The header exposes the client IP address by design, so it is privacy-sensitive Source 4সোর্স 4.
সহজ English
- Trusting
X-Forwarded-Forfor security. Anyone can send this header. Only addresses added by a trusted proxy are safe for rate limiting or IP-based access control. Other parts of the header may be spoofed Source 4সোর্স 4. - Leaving the app server open to the Internet. If the server can be reached directly, no part of the list is trustworthy. This is true even when a trusted reverse proxy is also in front of it Source 4সোর্স 4.
- Reading only one of several headers. Using only one
X-Forwarded-Forheader is not enough Source 4সোর্স 4. - Forgetting the privacy side. The header exposes the client IP address by design, so it is privacy-sensitive Source 4সোর্স 4.
বাংলা ব্যাখ্যা
- নিরাপত্তার জন্য
X-Forwarded-Forবিশ্বাস করা। যে কেউ এই হেডার পাঠাতে পারে। শুধু একটি বিশ্বস্ত প্রক্সির যোগ করা অ্যাড্রেস রেট লিমিটিং বা IP-ভিত্তিক অ্যাক্সেস কন্ট্রোলের জন্য নিরাপদ। হেডারের অন্য অংশ স্পুফ করা হতে পারে Source 4সোর্স 4। - অ্যাপ সার্ভারকে ইন্টারনেটে খোলা রাখা। সার্ভারে সরাসরি পৌঁছানো গেলে, তালিকার কোনো অংশই বিশ্বাসযোগ্য নয়। এটি সত্য, এমনকি তার সামনে একটি বিশ্বস্ত রিভার্স প্রক্সি থাকলেও Source 4সোর্স 4।
- কয়েকটি হেডারের মধ্যে শুধু একটি পড়া। শুধু একটি
X-Forwarded-Forহেডার ব্যবহার করা যথেষ্ট নয় Source 4সোর্স 4। - প্রাইভেসির দিক ভুলে যাওয়া। হেডার ডিজাইন অনুযায়ীই ক্লায়েন্টের IP অ্যাড্রেস প্রকাশ করে, তাই এটি প্রাইভেসি-সংবেদনশীল Source 4সোর্স 4।
What a tester can check
Tutorial advice
These test ideas are the tutorial's own advice. They are not from a source.
- Read the status code. A 502 or 504 usually means the proxy is fine and the server behind it has a problem. Report it that way.
- Check the client IP. Send a request through the proxy and look at the IP in the app log. It must be the client address, not the proxy address.
- Send a fake header. Add your own
X-Forwarded-Forto a request. The app must not trust it for rate limits or access rules. - Try the server directly. In a test environment, call the app server without the proxy. It should refuse, or give the same security result.
- Compare headers. Check
Host, the protocol, andViabefore and after the proxy. - Stop one app server. The proxy should send users to the other one, with no error page.
সহজ English
These test ideas are the tutorial's own advice. They are not from a source.
- Read the status code. A 502 or 504 usually means the proxy is fine and the server behind it has a problem. Report it that way.
- Check the client IP. Send a request through the proxy and look at the IP in the app log. It must be the client address, not the proxy address.
- Send a fake header. Add your own
X-Forwarded-Forto a request. The app must not trust it for rate limits or access rules. - Try the server directly. In a test environment, call the app server without the proxy. It should refuse, or give the same security result.
- Compare headers. Check
Host, the protocol, andViabefore and after the proxy. - Stop one app server. The proxy should send users to the other one, with no error page.
বাংলা ব্যাখ্যা
এই টেস্টের ধারণাগুলো টিউটোরিয়ালের নিজের পরামর্শ। এগুলো কোনো সোর্স থেকে নয়।
- স্ট্যাটাস কোড পড়ুন। 502 বা 504 সাধারণত মানে প্রক্সি ঠিক আছে এবং তার পেছনের সার্ভারে সমস্যা। সেভাবেই রিপোর্ট করুন।
- ক্লায়েন্টের IP দেখুন। প্রক্সি দিয়ে একটি রিকুয়েস্ট পাঠান এবং অ্যাপ লগে IP দেখুন। এটি ক্লায়েন্টের অ্যাড্রেস হতে হবে, প্রক্সির অ্যাড্রেস নয়।
- একটি নকল হেডার পাঠান। একটি রিকুয়েস্টে আপনার নিজের
X-Forwarded-Forযোগ করুন। অ্যাপকে রেট লিমিট বা অ্যাক্সেস রুলের জন্য তা বিশ্বাস করা চলবে না। - সরাসরি সার্ভার চেষ্টা করুন। একটি টেস্ট এনভায়রনমেন্টে প্রক্সি ছাড়া অ্যাপ সার্ভারকে কল করুন। অ্যাপ সার্ভারের উচিত প্রত্যাখ্যান করা, বা একই সিকিউরিটি ফল দেওয়া উচিত।
- হেডার তুলনা করুন। প্রক্সির আগে ও পরে
Host, প্রোটোকল এবংViaদেখুন। - একটি অ্যাপ সার্ভার বন্ধ করুন। প্রক্সির উচিত ইউজারদের অন্যটিতে পাঠানো, কোনো এরর পেজ ছাড়াই।
Key words
| Word | Meaning |
|---|---|
| Proxy | A program between two sides of a request that passes it on |
| Forward proxy | A proxy that a client uses to reach servers on the Internet |
| Reverse proxy | A proxy in front of servers; also called a gateway |
| Gateway | The HTTP standard name for a reverse proxy |
| Tunnel | A blind relay that passes messages without changing them |
| Upstream | The server behind the proxy that does the real work |
| X-Forwarded-For | A header that lists the client IP and the proxies on the way |
| Forwarded | The standard header for the same information |
| Via | A header that shows which proxies a message passed |
| 502 / 504 | Bad Gateway / Gateway Timeout: a problem between the proxy and the upstream server |