Fireship · @fireship

NGINX Explained in 100 Seconds

Uploaded October 16, 2020 · Length 2:05

NGINX Explained in 100 Seconds

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.

  1. 0:00

    nginx it's like a gateway that stands

  2. 0:02

    between the internet and your back-end

  3. 0:04

    infrastructure

  4. 0:05

    when you visit a web app the first place

  5. 0:06

    your request will go is to a web server

  6. 0:08

    its job is to look at the requested

  7. 0:10

    resource and determine where to find it

  8. 0:12

    on the server then send it back

  9. 0:14

    as the response in fact if you open up

  10. 0:16

    the network tab in chrome dev tools

  11. 0:17

    right now

  12. 0:18

    you can look at the server header on any

  13. 0:19

    response and there's a good chance it'll

  14. 0:21

    be nginx

  15. 0:22

    it's extremely popular with high traffic

  16. 0:24

    sites because it can handle more than 10

  17. 0:25

    000 simultaneous connections with its

  18. 0:27

    event driven architecture

  19. 0:29

    it's also commonly used as a reverse

  20. 0:30

    proxy where it acts as a traffic light

  21. 0:32

    to distribute the load to multiple

  22. 0:34

    backend servers while also providing

  23. 0:36

    security

  24. 0:36

    and caching for better performance in

  25. 0:39

    most cases it'll be installed on a linux

  26. 0:41

    server with the configuration file being

  27. 0:42

    found in the etc

  28. 0:44

    directory you customize the behavior of

  29. 0:45

    your server by defining directives

  30. 0:47

    a directive is just a key value pair or

  31. 0:50

    if followed by braces it's known as a

  32. 0:51

    context which itself holds more

  33. 0:53

    directives

  34. 0:54

    in the global context we might want to

  35. 0:55

    specify things like a username

  36. 0:57

    and where to save our error logs but

  37. 0:59

    most of your configuration will likely

  38. 1:01

    be done in the http context

  39. 1:03

    now one of the most important roles of

  40. 1:04

    nginx is to serve out static content

  41. 1:06

    like

  42. 1:07

    images and html we can handle that in

  43. 1:09

    the http context where we'll define one

  44. 1:12

    or more servers

  45. 1:12

    each server is distinguished by the port

  46. 1:14

    that it listens to nginx will keep track

  47. 1:17

    of every request to the server

  48. 1:18

    which you can write to an access log the

  49. 1:20

    most important thing though is to tell

  50. 1:22

    the server where to find the raw files

  51. 1:24

    which we do in the location context

  52. 1:26

    now when a user navigates to our domain

  53. 1:27

    it knows where to find the html

  54. 1:29

    on the file system and we might want to

  55. 1:31

    set up a second location

  56. 1:32

    to match any image pattern to the images

  57. 1:34

    directory other common things you might

  58. 1:36

    handle in your server config

  59. 1:37

    include ssl certificates rewrites and

  60. 1:40

    routing to a proxy server when i replace

  61. 1:42

    root with proxy pass

  62. 1:43

    i can point to a completely different

  63. 1:45

    server on the internet what we've

  64. 1:46

    created is a reverse proxy that can

  65. 1:48

    handle caching

  66. 1:49

    anonymity and load balancing this has

  67. 1:51

    been nginx in 100 seconds

  68. 1:53

    hit the like button if you want to see

  69. 1:54

    more short videos like this thanks for

  70. 1:56

    watching

  71. 1:56

    and i will see you in the next one