We may earn an affiliate commission when you visit our partners.
Course image
Hussein Nasser

NGINX is an open-source web server written in C and can also be used as a reverse proxy and a load balancer.   This class Is an introduction to NGINX, by the end of this class you will be able to understand the fundamentals of NGINX and spin up your own instance and even secure it with a legitimate certificate. 

Here are the topics that I will discuss:

Read more

NGINX is an open-source web server written in C and can also be used as a reverse proxy and a load balancer.   This class Is an introduction to NGINX, by the end of this class you will be able to understand the fundamentals of NGINX and spin up your own instance and even secure it with a legitimate certificate. 

Here are the topics that I will discuss:

  • What is NGINX?

  • NGINX Use Cases

  • Layer 4 and Layer 7 Proxying in Nginx

  • NGINX Timoouts

  • Example

    • Install Nginx (mac) 

    • Nginx as a Web Server 

      • Static content

      • Regular expression in NGINX

      • proxy_pass

    • Nginx as a Layer 7 Proxy

      • Proxy to 4 backend NodeJS services (docker)

      • IP_Hash load balancing

      • Split load to multiple backends (app1/app2)

      • Block certain requests (/admin)

    • NGINX as a Layer 4 Proxy

    • Create DNS record

    • Enable HTTPS on NGINX (lets encrypt)

    • Enable TLS 1.3 on NGINX

    • Enable HTTP/2 on NGINX

A small blurb about NGINX

NGINX is one of a handful of servers written to address the C10K problem. Unlike traditional servers, NGINX doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load. Even if you don’t expect to handle thousands of simultaneous requests, you can still benefit from NGINX’s high-performance and small memory footprint. NGINX scales in all directions: from the smallest VPS all the way up to large clusters of servers.

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • Layer 7 load balancing between services
  • Layer 4 load balancing between services
  • Setup nginx as a web server
  • Tls passthrough vs tls termination
  • Block undesired requests and re-route requests to different services
  • Enable https with letsencrypt
  • Enable http/2 with nginx
  • Enable tls 1.3 with nginx
  • Nginx timeouts
  • Scaling websockets with nginx
  • Load balancing websockets with nginx
  • Show more
  • Show less

Syllabus

Introduction to NGINX fundamentals
Introduction
Download Slides here
What is NGINX?
Read more
NGINX Use Cases
Layer 4 and Layer 7 Load Balancing in NGINX
TLS Termination and TLS Passthrough
NGINX Internal Architecture
Threading and Connections
NGINX Threading Architecture
Running NGINX in Docker
What are we building?
Download source code and config here
NGINX WebServer Container
Three Node app containers with NGINX in One Docker Network
Two NGINX containers load balancing to same backends
10 Node JS containers, 2 NGINX containers
Docker networking
Exploring few NGINX timeouts on both the frontend and the backend. Configuring these timeouts properly can make your backend much more efficient with high response time
NGINX Frontend Timeouts

Syntax:

client_header_timeout time;

Default:

client_header_timeout 60s;

Context:

http, server

Defines a timeout for reading client request header. If a client does not transmit the entire header within this time, the request is terminated with the 408 (Request Time-out) error.

Syntax:

client_body_timeout time;

Default:

client_body_timeout 60s;

Context:

http, server, location

Defines a timeout for reading client request body. The timeout is set only for a period between two successive read operations, not for the transmission of the whole request body. If a client does not transmit anything within this time, the request is terminated with the 408 (Request Time-out) error.

Syntax:

send_timeout time;

Default:

send_timeout 60s;

Context:

http, server, location

Sets a timeout for transmitting a response to the client. The timeout is set only between two successive write operations, not for the transmission of the whole response. If the client does not receive anything within this time, the connection is closed.


Syntax:

keepalive_timeout timeout [header_timeout];

Default:

keepalive_timeout 75s;

Context:

http, server, location

The first parameter sets a timeout during which a keep-alive client connection will stay open on the server side. The zero value disables keep-alive client connections. The optional second parameter sets a value in the “Keep-Alive: timeout=time” response header field. Two parameters may differ.

The “Keep-Alive: timeout=time” header field is recognized by Mozilla and Konqueror. MSIE closes keep-alive connections by itself in about 60 seconds.



Syntax:

lingering_timeout time;

Default:

lingering_timeout 5s;

Context:

http, server, location

When lingering_close is in effect, this directive specifies the maximum waiting time for more client data to arrive. If data are not received during this time, the connection is closed. Otherwise, the data are read and ignored, and nginx starts waiting for more data again. The “wait-read-ignore” cycle is repeated, but no longer than specified by the lingering_time directive.




Syntax:

resolver_timeout time;

Default:

resolver_timeout 30s;

Context:

http, server, location

Sets a timeout for name resolution, for example:

resolver_timeout 5s;


NGINX Backend Timeouts


Syntax:

proxy_connect_timeout time;

Default:

proxy_connect_timeout 60s;

Context:

http, server, location

Defines a timeout for establishing a connection with a proxied server. It should be noted that this timeout cannot usually exceed 75 seconds.


Syntax:

proxy_send_timeout time;

Default:

proxy_send_timeout 60s;

Context:

http, server, location

Sets a timeout for transmitting a request to the proxied server. The timeout is set only between two successive write operations, not for the transmission of the whole request. If the proxied server does not receive anything within this time, the connection is closed.




Syntax:

proxy_read_timeout time;

Default:

proxy_read_timeout 60s;

Context:

http, server, location

Defines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the proxied server does not transmit anything within this time, the connection is closed.

Syntax:

proxy_next_upstream_timeout time;

Default:

proxy_next_upstream_timeout 0;

Context:

http, server, location

This directive appeared in version 1.7.5.

Limits the time during which a request can be passed to the next server. The 0 value turns off this limitation.


Syntax:

keepalive_timeout timeout;

Default:

keepalive_timeout 60s;

Context:

upstream

This directive appeared in version 1.15.3.

Sets a timeout during which an idle keepalive connection to an upstream server will stay open.



This section is filled with examples
Read this before you continue with this section

Find the code here https://github.com/hnasr/javascript_playground/tree/master/docker


Working with NGINX - What will we do?
Installing NGINX
NGINX as a Web Server
NGINX as a Layer 7 Proxy
NGINX as a Layer 4 Proxy
Enable HTTPS on NGINX
Enabling Fast and Secure TLS 1.3 on NGINX
Enable HTTP/2 on NginX
WebSockets protocol is a bidirectional communication protocol and having NGINX proxy and load balance this protocol can be tricky, in this section I discuss the fundamentals of WebSockets with NGINX
Download section slides, code, config and resources here
NGINX and WebSockets Agenda
Introduction to WebSockets
Layer 4 vs Layer 7 WebSockets Proxying
Spin up a WebSockets Server
Configure NGINX as Layer 4 WebSocket Proxying
Configure NGINX as Layer 7 WebSocket Proxying
Section Summary
Answering your Questions
How to Scale NGINX?
How many Backends do we need for NGINX?
Bonus Content
NGINRat - a remote access trojan injecting NGINX (article)
Bonus - Proxy vs Reverse Proxy
NGINX Process Architecture
The Limitations of NGINX which made Cloudflare build their own proxy
Course Summary

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Teaches a high number of fundamental Nginx concepts and skills
Offers practical examples and hands-on configurations
Covers important topics like layer 4/7 load balancing, HTTPS configuration, and TLS optimization
Provides a comprehensive understanding of Nginx's architecture and its use cases
Taught by an experienced instructor with expertise in Nginx
Suitable for beginners to intermediate learners seeking a strong foundation in Nginx

Save this course

Save Introduction to NGINX to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Introduction to NGINX with these activities:
Review the basics of NGINX
Having a strong understanding of the basics of NGINX is necessary for getting the most out of this course. This will lay the foundation for understanding the more advanced topics covered later.
Browse courses on nginx
Show steps
  • Read the NGINX documentation
  • Watch a tutorial on NGINX
Organize Course Resources for Future Reference
Facilitate efficient learning by organizing course materials, such as notes, assignments, and quizzes, for easy access and future review.
Browse courses on Resource Management
Show steps
  • Create a dedicated folder or digital notebook for the course materials.
  • Regularly add notes, assignments, and other relevant materials to the designated location.
  • Consider using digital tools for organizing and annotating the materials.
Review Fundamentals of Web Servers and Networking
Strengthen your understanding of web servers and networking concepts, which are essential for comprehending NGINX and its applications.
Browse courses on Networking Basics
Show steps
  • Revisit concepts related to web server architecture and functionality.
  • Review the basics of networking, including IP addresses, ports, and protocols.
  • Consider referring to online resources or introductory materials on these topics.
Six other activities
Expand to see all activities and additional details
Show all nine activities
Review `HTTP: The Definitive Guide`
Provide a thorough understanding of the Hypertext Transfer Protocol (HTTP), which is essential for web development and networking.
Show steps
  • Read chapters 1-3 to gain a foundational understanding of HTTP concepts and architecture.
  • Review chapters 4-6 to explore HTTP methods, status codes, and message formats.
  • Focus on chapters 7-9 to learn about HTTP caching, security, and performance optimization.
Configure NGINX for a Basic Web Application
Solidify your understanding by setting up and configuring NGINX for a simple web application, applying your knowledge to a real-world scenario.
Show steps
  • Choose a simple web application, such as a static website or a basic blog.
  • Set up the necessary infrastructure, including the web application and NGINX.
  • Configure NGINX to serve the web application and handle incoming requests.
  • Test the configuration by accessing the web application through NGINX.
Develop a Simple NGINX Proxy Configuration
Reinforce your understanding of NGINX by creating a basic proxy configuration, allowing you to apply the concepts covered in the course practically.
Browse courses on Web Server Configuration
Show steps
  • Create a simple NGINX configuration file with a basic proxy directive.
  • Set up a web server to act as the backend for the proxy.
  • Test the proxy configuration by accessing the backend server through the NGINX proxy.
Complete NGINX Tutorials on the Official Website
Supplement your learning by following guided tutorials provided by NGINX, ensuring a comprehensive understanding of the platform.
Show steps
  • Visit the NGINX official website and navigate to the documentation section.
  • Choose a tutorial relevant to the topics covered in the course, such as 'NGINX Reverse Proxy'.
  • Follow the tutorial steps, implementing the configurations on your local machine.
Join a Study Group or Online Forum for NGINX
Foster a deeper understanding through peer interaction, sharing knowledge, and discussing NGINX concepts and challenges within a study group or online forum.
Show steps
  • Identify or join an existing study group or online forum focused on NGINX.
  • Participate actively in discussions, asking questions, providing insights, and engaging with other members.
  • Collaborate on projects or troubleshooting issues related to NGINX.
Troubleshoot Common NGINX Configuration Issues
Enhance your problem-solving skills by identifying and resolving common NGINX configuration issues, fostering a deeper understanding of the platform.
Show steps
  • Review the NGINX error log to identify potential issues.
  • Use the 'nginx -t' command to check for syntax errors in your configuration file.
  • Refer to online resources or NGINX documentation for specific error codes and solutions.

Career center

Learners who complete Introduction to NGINX will develop knowledge and skills that may be useful to these careers:
Web Developer
Web Developers build and maintain websites. This course introduces Nginx, which is a popular web server software. Nginx can be used to improve the performance and security of websites. Developers who are familiar with Nginx are more likely to be successful in building and maintaining high-quality websites.
Software Engineer
Software Engineers design, develop, and maintain software systems. Nginx is a powerful web server software that can be used to improve the performance and security of software systems. Software Engineers who are familiar with Nginx are more likely to be successful in building and maintaining high-quality software systems.
Systems Administrator
Systems Administrators manage and maintain computer systems. Nginx is a popular web server software that can be used to improve the performance and security of computer systems. Systems Administrators who are familiar with Nginx are more likely to be successful in managing and maintaining high-quality computer systems.
Network Engineer
Network Engineers design, build, and maintain computer networks. Nginx is a popular web server software that can be used to improve the performance and security of computer networks. Network Engineers who are familiar with Nginx are more likely to be successful in designing, building, and maintaining high-quality computer networks.
Cloud Architect
Cloud Architects design and manage cloud computing systems. Nginx is a popular web server software that can be used to improve the performance and security of cloud computing systems. Cloud Architects who are familiar with Nginx are more likely to be successful in designing and managing high-quality cloud computing systems.
Data Analyst
Data Analysts collect, analyze, and interpret data. Nginx is a powerful web server software that can be used to improve the performance and security of data analysis systems. Data Analysts who are familiar with Nginx are more likely to be successful in building and maintaining high-quality data analysis systems.
Information Security Analyst
Information Security Analysts protect computer systems and networks from cyber attacks. Nginx is a popular web server software that can be used to improve the security of computer systems and networks. Information Security Analysts who are familiar with Nginx are more likely to be successful in protecting computer systems and networks from cyber attacks.
DevOps Engineer
DevOps Engineers collaborate with developers and operations teams to build and maintain software systems. Nginx is a popular web server software that can be used to improve the performance and security of software systems. DevOps Engineers who are familiar with Nginx are more likely to be successful in building and maintaining high-quality software systems.
Quality Assurance Analyst
Quality Assurance Analysts test and evaluate software systems to ensure that they meet quality standards. Nginx is a popular web server software that can be used to improve the performance and security of software systems. Quality Assurance Analysts who are familiar with Nginx are more likely to be successful in testing and evaluating high-quality software systems.
Technical Support Specialist
Technical Support Specialists provide technical support to users of computer systems and networks. Nginx is a popular web server software that can be used to improve the performance and security of computer systems and networks. Technical Support Specialists who are familiar with Nginx are more likely to be successful in providing technical support to users of computer systems and networks.
Product Manager
Product Managers manage the development and marketing of products. Nginx is a popular web server software that can be used to improve the performance and security of products. Product Managers who are familiar with Nginx are more likely to be successful in managing the development and marketing of high-quality products.
Business Analyst
Business Analysts analyze business processes and systems to identify opportunities for improvement. Nginx is a popular web server software that can be used to improve the performance and security of business processes and systems. Business Analysts who are familiar with Nginx are more likely to be successful in identifying opportunities for improvement in business processes and systems.
Project Manager
Project Managers plan and manage projects. Nginx is a popular web server software that can be used to improve the performance and security of projects. Project Managers who are familiar with Nginx are more likely to be successful in planning and managing high-quality projects.
IT Consultant
IT Consultants provide consulting services to businesses on how to use technology to improve their operations. Nginx is a popular web server software that can be used to improve the performance and security of business operations. IT Consultants who are familiar with Nginx are more likely to be successful in providing consulting services to businesses on how to use technology to improve their operations.
Sales Engineer
Sales Engineers sell technology products and services to businesses. Nginx is a popular web server software that can be used to improve the performance and security of business operations. Sales Engineers who are familiar with Nginx are more likely to be successful in selling technology products and services to businesses.

Reading list

We've selected 13 books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Introduction to NGINX.
Provides a deep dive into the inner workings of browser networking. It valuable resource for anyone who wants to learn more about how NGINX works and how to use it to improve the performance of web applications.
Provides a comprehensive overview of web application security. It valuable resource for anyone who wants to learn more about how to secure NGINX and their websites.
Provides a comprehensive overview of DevOps practices. It valuable resource for anyone who wants to learn more about how to improve the efficiency and effectiveness of their IT organization.
Provides a comprehensive overview of the principles of scalability. It valuable resource for anyone who wants to learn more about how to scale NGINX and their websites.
Novel that tells the story of a team of IT professionals who are tasked with saving their company from a major outage. It valuable resource for anyone who wants to learn more about DevOps practices and how to improve the efficiency and effectiveness of their IT organization.
Provides a practical guide to building scalable web applications. It valuable resource for anyone who wants to learn more about how to use NGINX to build scalable websites.
Provides a comprehensive overview of the Lean Startup methodology. It valuable resource for anyone who wants to learn more about how to build a successful startup.
Provides a comprehensive overview of OpenSSL and how to use it to secure web applications. It valuable resource for anyone who wants to learn more about how to use NGINX to secure their websites.
Provides a comprehensive overview of HTTP. It valuable resource for anyone who wants to learn more about how NGINX works and how to use it to improve the performance of their websites.
Provides a comprehensive overview of the TLS protocol. It covers topics such as the TLS architecture, performance, and security. It valuable resource for anyone who wants to learn more about how to use TLS.
Provides a comprehensive overview of TCP/IP. It valuable resource for anyone who wants to learn more about how NGINX works and how to use it to improve the performance of their websites.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser