![]() |
VOOZH | about |
In this guide, we will discuss Nginx’s http proxying capabilities, which allow Nginx to pass requests off to backend http servers for further processing. Nginx is often set up as a reverse proxy solution to help scale out infrastructure or to pass requests to other servers that are not designed to handle large client loads.
Along the way, we will discuss how to scale out using Nginx’s built-in load balancing capabilities. We will also explore buffering and caching to improve the performance of proxying operations for clients.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Former Senior Technical Writer at DigitalOcean, specializing in DevOps topics across multiple Linux distributions, including Ubuntu 18.04, 20.04, 22.04, as well as Debian 10 and 11.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Very, very, very well written and thorough!
This comment has been deleted
Little correction: “key_zone” must be corrected to “keys_zone”. Nginx does not very much information in errors.log
Hi Justin - really great tutorial.
Actually, what I am specifically trying to get running well is NGINX server blocks using Docker containers - with NGINX as both the host reverse proxy, and the web server inside the Docker containers - which are in turn all running Wordpress.
It would be great for me - and I suspect a lot of Digital Ocean users - if you could write such a tutorial - so basically we could run many Wordpress Docker containers inside a single Droplet.
If this can add some good luck - my best friend is also a technical writer named Justin - though he is from Montreal. Thanks profusely.
Thank you! illuminating and easy to read :-)
Very good article, Justin. Thank you, that’s what I’ve been looking for.
And I have another question about buffering.
Does Nginx also buffer http request from client? I mean, if Nginx get a http request from client, does it create connection with upstream server immediatly? Or it will create connection after it get a whole http request?
You know, many application server frameworks use worker-thread-pool model. If the client machine is far from Nginx and upstream server, without buffering http request in Nginx side, upstream server will waste pretty much CPU resource on waiting for completing a http request.
Thanks.
Awesome, It’s very useful for me to use with NODE.JS also for the new learner, Fantastic :)
Hi, i’ve been trying to find this for hours. How do i get the server name chosen in upstream group at request. Thanks. $upstream_addr returns ip address
@jellingwood hi this is what i want to do
say i have
upstream myapp1 {
server www.abc.com:80;
server www.asd.com:80;
}
server {
listen 80;
location / {
proxy_set_header Host XXxXXX; //this
… }
i want to set XXxxXXX as www.abc.com or www.asd.com based on whatever upstream server is chosen. I’ve been trying using conditonals, map, etc. But i’m new so im not getting anywhere.
the var upstreamd_addr gives ip not the domain name.
thanks for helping me out…
if server hasn’t been selected then how come i can get $upstream_addr right. I just wish i could get $upstream_url or something.
What i want to do is do load balancing AND use different sites. It’s weird. But that’s what i’m trying to do.
for reasons beyond my control however both asd.com and abc.com only respond if host header has their url in them.
therefore using map, conditional, variable, directive, default or whatever goes. I’m trying to set host header to the same domain. I can get upstream addr but not upstream url.
is there a way to program conditions in here or define default headers for each upstream.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.