Nginx can sit in front of one application server or a pool of them. In that position, it accepts the client connection, forwards requests with proxy_pass, distributes traffic among upstream servers, buffers responses, and optionally serves cacheable responses without contacting the application every time. The right configuration depends on whether your priority is simple routing, uneven backend capacity, session persistence, streaming latency, or reduced upstream work.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What nginx does in a reverse-proxy architecture
A client normally connects to nginx rather than directly to an application. Nginx then opens or reuses a connection to an upstream server, sends the request, receives the response, and returns that response to the client. The application can therefore remain on a private network while nginx handles the public listener, connection management, routing, buffering, and caching policy.
As an Amazon Associate I earn from qualifying purchases.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →The proxy_pass directive is the switch that makes an HTTP location a reverse proxy. Nginx is also capable of acting as an HTTP web server, content cache, load balancer, TCP/UDP proxy server, and mail proxy server, but the directives and processing rules differ between those roles.
A minimal reverse-proxy server
http {
upstream app_backend {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name example.test;
location / {
proxy_pass http://app_backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
This example forwards every path to the upstream named app_backend. The forwarded headers preserve the original host, client address, proxy chain, and request scheme for applications that need them. In production, validate the configuration with nginx -t and reload nginx using the service manager used by your operating system.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
What happens to one request
- Client connection: nginx accepts the connection and selects a matching
serverandlocation. - Upstream selection:
proxy_passpoints the request at one server or anupstreamgroup. - Request forwarding: nginx sends the method, URI, headers, and body according to the proxy directives in scope.
- Response handling: nginx receives status, headers, and body data, then either buffers or streams that data toward the client.
- Optional cache decision: if proxy caching is configured, nginx can serve a fresh stored response or fetch and store a new one.
Choosing an nginx load-balancing method
When an upstream group has multiple servers and no method is explicitly configured, nginx uses round-robin. It distributes successive requests across the available servers in turn. That is a sensible starting point when backends have similar capacity and requests have broadly similar cost.
| Method or setting | How nginx chooses a server | Best fit | Main trade-off |
|---|---|---|---|
| Round-robin | Cycles through the upstream servers; this is the default when no method is specified. | Comparable servers and ordinary stateless HTTP traffic. | Does not account for a server currently handling longer or more expensive requests. |
least_conn |
Favors the server with the fewest active connections. | Workloads where connection duration varies substantially. | A connection count is only a proxy for actual work; one request may be far more expensive than another. |
least_time |
Considers response timing when selecting a server. | Backends with different response speeds or changing load. | Timing-based decisions can move traffic toward a fast server before another factor, such as application saturation, is visible. |
ip_hash |
Uses the client IP to favor the same upstream server for that client. | Legacy applications that keep session state locally and cannot share it. | Clients behind a common NAT address can cluster on one backend, and mobile or changing addresses can reduce persistence. |
| Server weights | Assigns a relative weight so stronger servers receive a larger share. | Mixed-capacity or deliberately phased deployments. | Weights express intended capacity; they do not prove that a server is healthy or that requests cost the same. |
Round-robin for a uniform pool
upstream app_backend {
server 10.0.0.11;
server 10.0.0.12;
server 10.0.0.13;
}
Use this when each server can handle approximately the same traffic and the application does not require a particular client to return to a particular node. Shared sessions, shared files, or a separate session store make this approach easier to operate.
Recommended Free Tools
Least connections for uneven request duration
upstream app_backend {
least_conn;
server 10.0.0.11;
server 10.0.0.12;
}
least_conn can prevent a backend that is already holding many long-lived requests from receiving the next request. It is not a universal “fastest server” setting: active connection counts do not measure CPU, queue depth, database waits, or the cost of a newly arriving request.
Least time when response speed matters
least_time considers response timing and is useful when observed latency differs between backends. Treat it as a workload-specific choice. A server can respond quickly to a small request while still being a poor choice for a large upload or a database-heavy endpoint.
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
IP hash for local session state
upstream app_backend {
ip_hash;
server 10.0.0.11;
server 10.0.0.12;
}
IP persistence is a workaround for applications that store session state on one node. It is not the same as reliable user identity: many users may share one public address, and a user’s address can change. Where possible, make the application session-aware across the pool instead of depending on affinity.
Weights for mixed hardware or migrations
upstream app_backend {
server 10.0.0.11 weight=3;
server 10.0.0.12 weight=1;
}
The values are relative, not percentages that must total a particular number. A weight of 3 gives the first server more traffic than a weight of 1 under the balancing method in use. During a migration, a lower weight can expose a new backend gradually, but monitor errors and latency while doing so.
Free tools Windows power users keep installed
One-click scans. No signup required.
Failure handling and health checks
Open-source nginx performs passive health checking. It observes communication failures while serving real traffic and can temporarily avoid an upstream that is failing. This is different from actively sending a synthetic application request to every server at regular intervals.
The proxy_next_upstream directive controls conditions under which nginx may try another upstream server. Define the failure conditions deliberately: retrying a request after a connection failure is different from retrying after a response has already been sent, and repeating a non-idempotent request can create duplicate work. Confirm how your application handles retries before enabling broad retry behavior.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
location / {
proxy_pass http://app_backend;
proxy_next_upstream error timeout http_502 http_503 http_504;
}
Passive avoidance cannot detect every application failure. A process may accept TCP connections while returning an error page, serving corrupted data, or failing one dependency. Richer application health checks, activity monitoring, and dynamic upstream reconfiguration are features associated with NGINX Plus rather than the open-source feature set described here.
Response buffering: what proxy_buffering changes
proxy_buffering is enabled by default. With buffering on, nginx reads the upstream response into memory as quickly as it can and sends data to the client while continuing to read from the upstream. If the configured memory buffers cannot hold all the data currently in flight, nginx can write part of the response to a temporary file.
This decouples an application server from a slow client. The upstream can finish and release its connection instead of remaining occupied while a user on a slow network consumes the response. The cost is memory use and, when buffers fill, temporary-file I/O.
The buffering directives
| Directive | Purpose | Operational question |
|---|---|---|
proxy_buffering |
Enables or disables buffering of responses from the proxied server. | Should nginx absorb client-speed differences, or must data reach the client immediately? |
proxy_buffer_size |
Sets the buffer used for the first part of the response, normally the response headers. | Are headers unusually large, for example because of many cookies? |
proxy_buffers |
Sets the number and size of additional buffers used for the response body. | Can the expected response fit in memory, and how many concurrent responses must be supported? |
When buffering should stay on
- HTML pages, API responses, and downloads where the upstream should be freed quickly.
- Clients with widely varying network speeds.
- Deployments where smoothing bursts is more important than delivering each byte at the lowest possible latency.
When disabling buffering may be appropriate
Streaming endpoints, server-sent events, long polling, and other low-latency feeds may need data forwarded as it arrives. A location-specific configuration can disable buffering:
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
location /events/ {
proxy_pass http://app_backend;
proxy_buffering off;
}
Disabling buffering does not automatically make an application a correct streaming service. The upstream must flush data, intermediary timeouts must allow the connection to remain open, and the client must process incremental data. Conversely, leaving buffering on for a high-volume stream can increase memory or temporary-file pressure.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How nginx proxy caching works
Proxy caching stores responses from an upstream so later matching requests can be answered without contacting the application. A usable cache needs both a storage definition and a location that selects it. proxy_cache_path defines where files are stored and creates a shared-memory key zone; proxy_cache selects that zone for a location.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=app_cache:10m max_size=1g inactive=60m use_temp_path=off;
upstream app_backend {
server 127.0.0.1:8080;
}
server {
listen 80;
location / {
proxy_pass http://app_backend;
proxy_cache app_cache;
proxy_cache_valid 200 10m;
proxy_cache_valid 404 1m;
}
}
}
The path, zone size, maximum size, inactivity period, and validity durations in this example are configuration choices, not universal recommendations. Set them according to response size, disk capacity, request volume, and how quickly content is allowed to become stale.
Freshness and response headers
proxy_cache_valid assigns cache durations by response status. Upstream response headers can also control freshness: X-Accel-Expires, Expires, and Cache-Control can set or override how long a response is considered fresh. Decide which layer owns that policy. If the application emits authoritative cache headers, avoid silently replacing them with a longer nginx lifetime.
Best Value
Revalidation, duplicate fills, and stale responses
proxy_cache_revalidatelets nginx revalidate an expired cached response with the upstream instead of always downloading a complete replacement.proxy_cache_lockprevents many simultaneous misses for the same key from all fetching the same object at once. Other requests wait for the first fill according to the configured lock behavior.proxy_cache_use_staleallows nginx to serve an older cached response during selected failures or updates. The permitted conditions should be explicit because stale data is a deliberate availability trade-off.
Do not cache every request
Authentication, personalized pages, shopping carts, account changes, and requests with side effects generally need bypass rules rather than blanket caching. A cache key must distinguish responses that are genuinely interchangeable. Cookies, authorization headers, query strings, request methods, and content negotiation can all affect whether two requests may safely share an object.
A practical design starts with a narrow location for public, read-only responses. Add bypass or no-cache conditions for authenticated traffic and mutating methods, then verify the result with response headers and logs. A cache hit that returns the wrong user’s data is a correctness failure, not merely a performance issue.
How proxying, balancing, buffering, and caching interact
These features solve different problems and should be tuned separately. Load balancing chooses an upstream. Buffering controls how nginx moves that upstream response between two connections. Caching can eliminate the upstream request entirely when a fresh object exists. A cache hit therefore bypasses the balancing decision for that request, while a cache miss uses the selected upstream and then may populate the cache.
For a public API, a common sequence is: round-robin or least-connection balancing, buffering enabled, and a short, explicit cache lifetime for safe GET responses. For a live event stream, use a dedicated location with caching disabled and buffering off. For a stateful legacy application, IP hash may be necessary until session state is moved out of individual nodes.
Open-source nginx and NGINX Plus
The open-source nginx feature set covers the documented proxy directives, round-robin and other balancing methods, passive failure handling, response buffering, and proxy caching. NGINX Plus adds application health checks, activity monitoring, and dynamic upstream reconfiguration. Choose the edition based on whether those operational features are required; do not assume that an open-source passive check is equivalent to an active application probe.
Configuration checklist and troubleshooting
Before deploying a change
- Confirm that every upstream address is reachable from the nginx host.
- Check that the selected balancing method matches session and capacity requirements.
- Decide whether retries are safe for each request type.
- Measure response sizes and concurrency before changing buffer sizes.
- Define cacheable methods, cache keys, freshness headers, bypass rules, and stale conditions.
- Run
nginx -t, then reload rather than stopping the service when a graceful configuration change is sufficient.
If clients receive 502, 503, or 504 responses
- Check upstream reachability, listening ports, and name resolution from the nginx machine.
- Inspect whether passive failure handling has temporarily removed servers after communication errors.
- Review
proxy_next_upstreamconditions and retry behavior. - Compare upstream response time with proxy timeouts; a timeout can look like an unavailable backend even when the application is still working.
If memory or disk usage rises
- Review
proxy_buffers, response sizes, and concurrent buffered requests. - Look for temporary files created when responses exceed available memory buffers.
- For cache growth, inspect the cache path, maximum size, inactivity policy, and object lifetime.
- Keep streaming locations separate so long-lived responses do not compete with ordinary pages for the same buffering assumptions.
If users see stale or incorrect content
- Verify the cache key and whether cookies, authorization, query parameters, or content negotiation change the response.
- Check upstream
Cache-Control,Expires, andX-Accel-Expiresheaders againstproxy_cache_valid. - Inspect revalidation, lock, bypass, and stale-serving rules.
- Exclude personalized and state-changing responses instead of trying to repair them with a longer or shorter TTL.
The Bottom Line
Start with proxy_pass and default round-robin for a simple, stateless application. Move to least_conn, least_time, IP hashing, or weights only when the workload justifies it. Keep buffering enabled for ordinary responses unless slow clients are harming upstream capacity; disable it selectively for streaming. Add caching only with an explicit cache zone, freshness policy, safe bypass rules, and a deliberate stale-content strategy.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




