Fireship · @fireship
NGINX Explained in 100 Seconds
Uploaded October 16, 2020 · Length 2:05
Summary
nginx explained as a gateway for web servers, handling connections, caching, and security.
- nginx
- reverse proxy
- web server
- linux
- ssl certificates
- load balancing
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
nginx it's like a gateway that stands
- 0:02
between the internet and your back-end
- 0:04
infrastructure
- 0:05
when you visit a web app the first place
- 0:06
your request will go is to a web server
- 0:08
its job is to look at the requested
- 0:10
resource and determine where to find it
- 0:12
on the server then send it back
- 0:14
as the response in fact if you open up
- 0:16
the network tab in chrome dev tools
- 0:17
right now
- 0:18
you can look at the server header on any
- 0:19
response and there's a good chance it'll
- 0:21
be nginx
- 0:22
it's extremely popular with high traffic
- 0:24
sites because it can handle more than 10
- 0:25
000 simultaneous connections with its
- 0:27
event driven architecture
- 0:29
it's also commonly used as a reverse
- 0:30
proxy where it acts as a traffic light
- 0:32
to distribute the load to multiple
- 0:34
backend servers while also providing
- 0:36
security
- 0:36
and caching for better performance in
- 0:39
most cases it'll be installed on a linux
- 0:41
server with the configuration file being
- 0:42
found in the etc
- 0:44
directory you customize the behavior of
- 0:45
your server by defining directives
- 0:47
a directive is just a key value pair or
- 0:50
if followed by braces it's known as a
- 0:51
context which itself holds more
- 0:53
directives
- 0:54
in the global context we might want to
- 0:55
specify things like a username
- 0:57
and where to save our error logs but
- 0:59
most of your configuration will likely
- 1:01
be done in the http context
- 1:03
now one of the most important roles of
- 1:04
nginx is to serve out static content
- 1:06
like
- 1:07
images and html we can handle that in
- 1:09
the http context where we'll define one
- 1:12
or more servers
- 1:12
each server is distinguished by the port
- 1:14
that it listens to nginx will keep track
- 1:17
of every request to the server
- 1:18
which you can write to an access log the
- 1:20
most important thing though is to tell
- 1:22
the server where to find the raw files
- 1:24
which we do in the location context
- 1:26
now when a user navigates to our domain
- 1:27
it knows where to find the html
- 1:29
on the file system and we might want to
- 1:31
set up a second location
- 1:32
to match any image pattern to the images
- 1:34
directory other common things you might
- 1:36
handle in your server config
- 1:37
include ssl certificates rewrites and
- 1:40
routing to a proxy server when i replace
- 1:42
root with proxy pass
- 1:43
i can point to a completely different
- 1:45
server on the internet what we've
- 1:46
created is a reverse proxy that can
- 1:48
handle caching
- 1:49
anonymity and load balancing this has
- 1:51
been nginx in 100 seconds
- 1:53
hit the like button if you want to see
- 1:54
more short videos like this thanks for
- 1:56
watching
- 1:56
and i will see you in the next one


