DEV Community

loading...
Cover image for Nginx concepts I wish I knew years ago

Nginx concepts I wish I knew years ago

Aemie Jariwala on January 11, 2021

Nginx is a web server that is used as a reverse proxy, load balancer, mail proxy, and HTTP cache and follows the Master-Slave Architecture. Woah!...
pic
Editor guide
Collapse
ankurloriya profile image
Ankur Loriya

sudo nginix -T

For test configuration

Collapse
qz11 profile image
Yevazn

Great post!

I'm from HelloGitHub, a nonprofit organization in China. I am reaching out to you to ask if it's OK for us to translate your posts, "Nginx concepts I wish I knew years ago", into Chinese and publish it on our WeChat official account. You own the copyright of course.

How does that sound to you?

Collapse
aemiej profile image
Aemie Jariwala Author

First of all, thank you. As long as I own the copyright, I am fine with this. :)

Collapse
ggenya132 profile image
Eugene Vedensky

Thank you for the post, I'll use it as a reference whenever I need to work with NGINX.

Some minor thoughts: although it's probably intuitive to more experienced devs, I think it might be helpful to point out that NGINX will automatically serve static files marked as index.html. Also, in my head it makes more sense to initially show the location block without defining a new root within it to show that NGINX will search your previously defined root path to append the requested URI to before moving on to examples that redefine the root.

Thanks again for sharing.

Collapse
ben profile image
Ben Halpern

Great post!

Collapse
aemiej profile image
Collapse
bogkonstantin profile image
Konstantin Bogomolov

Good tool to learn how nginx match locations: nginx.viraptor.info/

Collapse
aemiej profile image
Aemie Jariwala Author

Thanks for this 😀

Collapse
shwetabh1 profile image
Shwetabh Shekhar

This is great, thanks for sharing!

Collapse
aemiej profile image
Aemie Jariwala Author

Thank you as well for reading!

Collapse
deven96 profile image
Diretnan Domnan

I finally understand, thanks! You've earned yourself a follower

Collapse
aemiej profile image
Aemie Jariwala Author

Glad to know!

Collapse
iamfazal profile image
Fazal ur Rehman

Well explained.!

Collapse
aemiej profile image
Collapse
kumbharumesh profile image
KMeshU

Good post!

Collapse
aemiej profile image
Collapse
mugiwarafx profile image
mugiwarafx

Great post, thanks for sharing!

Collapse
aemiej profile image
Aemie Jariwala Author

Thank you and the pleasure is all mine!

Collapse
kiranrs profile image
Kiran RS

Please create an article for Apache with nginx (as proxy server) with https.

Collapse
programmerraja profile image
Programmer Raja

Just awesome bro ✌️

Collapse
aemiej profile image
Collapse
mickorbik profile image
Mick Orbik

Solid post!

Collapse
aemiej profile image
Collapse
sysnet4admin profile image
Hoon Jo

So Impressive. !

Collapse
aemiej profile image
Aemie Jariwala Author

Thanks a lot!

Collapse
pianolinux profile image
Olaitan Adebowale

Thank you so much.. This is very helpful.
I can't wait for more of this..

Collapse
aemiej profile image
Aemie Jariwala Author

Sure thing and thankyou!

Collapse
saleheen profile image
Collapse
aemiej profile image
Aemie Jariwala Author

Thank you 😀

Collapse
taufiqtab profile image
Taufiq Abdullah

Great !, Very helpful thank u so much :)

Collapse
aemiej profile image
Aemie Jariwala Author

Glad to know! :)

Collapse
smithg09 profile image
Smith Gajjar

Great post, This is exactly what I was looking for...

Collapse
aemiej profile image
Aemie Jariwala Author

Thankyou Smith. Glad to know my article could be of help! ☺️

Collapse
iamfazal profile image
Fazal ur Rehman

Hey Aemie!
Can I use some of your's diagrams in my post?

I will surely give credits.

Collapse
aemiej profile image
Aemie Jariwala Author

I have myself used the diagrams from youtube tutorials & google images as mentioned but I have no problem!

Collapse
pankajrajput1462 profile image
pankajrajput1462

awesome article

Collapse
aemiej profile image
Collapse
fchaussin profile image
François CHAUSSIN

Great article, thanks for sharing

Collapse
aemiej profile image
Collapse
akshay03 profile image
Akshay Khot

Good article! Very informative.

Collapse
aemiej profile image
Collapse
nitinkatkam profile image
Nitin Reddy

Good article! I have a question about the format of the nginx.conf configuration file... it certainly isn't JSON. What format is it?

Collapse
germavinsmoke profile image
GermaVinsmoke

Atleast give the credits to the person whose diagram images you've used 😑

Collapse
aemiej profile image
Aemie Jariwala Author

Sorry I missed that. I've added all the credits. Thanks a lot for the advice 😀

Collapse
germavinsmoke profile image
GermaVinsmoke

Now it's good 😌👌

Collapse
jatinkumarg profile image
Jatin Kumar

This is a great summary on Nginx. Now, I can set it up myself 😎. Thank you!

Collapse
aemiej profile image
Aemie Jariwala Author

Pleasure is all mine!

Collapse
andreidascalu profile image
Andrei Dascalu

Well, you are wrong about the definition. A web server doesn't pass a request to a backed server. That's what a proxy does.

A webserver serves content. That's it. It handles the request and returns it's own response, whereas a reverse proxy proxies the response.

Even though the most efficient part of Nginx is its web server capability, it's widely used as a proxy/reverse proxy.

However there are much more capable proxies out there (unless you're using the enterprise version): thinking mainly of Haproxy and Traefik.

Collapse
simonholdorf profile image
Simon Holdorf

How about you say something like: thank you for the post and all the work you have put into this. I have slightly other opinions about X and want to share my version...

Yours sounds way too rude!

Collapse
andreidascalu profile image
Info Comment marked as low quality/non-constructive by the community. View code of conduct
Andrei Dascalu

You have a point, but I wouldn't want to ruin my reputation as a literal and figurative bastard. And I wouldn't want people to think I discriminate.

Collapse
aemiej profile image
Aemie Jariwala Author

In the article, I mentioned that the web server passes/directs the requests to the backend server. In the same sense that it's handling the connection between the client and the backend server. However, I agree with your definition as well hence thank you for your opinion! I will certainly look into those proxies as well. 😀

Collapse
skyjur profile image
Ski

Bit of hair splitting. Http reverse proxy IS a web server by definition of server as in TCP protocol node that acts as server in client-server connection.

Collapse
andreidascalu profile image
Andrei Dascalu

HTTP reverse proxy is a server (as in general term). Web server serves web content (as in WWW, eg: html/js). Sure, it's hair splitting, but the difference can be important in certain contexts. Eg: HAProxy is a reverse proxy, but NOT a web server as it's unable to actually serve content (it can only proxy it).

IMHO it's important to know the tools and what they can do to choose what's right.
A proxy can be, for example, a HTTP proxy or a TCP proxy. Some proxies can do both, some can only do HTTP by design.

Collapse
arv19626783 profile image
arv

Thank you @ameia. Can you please write an article a pie isn’t ngoni minx as websocket reverse proxy!