Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
NGINX HTTP Server
NGINX HTTP Server

NGINX HTTP Server: Harness the power of NGINX with a series of detailed tutorials and real-life examples , Fifth Edition

Arrow left icon
Profile Icon Gabriel Ouiran Profile Icon Fjordvald Profile Icon Nedelcu
Arrow right icon
€20.98 €29.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8 (4 Ratings)
eBook May 2024 262 pages 5th Edition
eBook
€20.98 €29.99
Paperback
€37.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Gabriel Ouiran Profile Icon Fjordvald Profile Icon Nedelcu
Arrow right icon
€20.98 €29.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8 (4 Ratings)
eBook May 2024 262 pages 5th Edition
eBook
€20.98 €29.99
Paperback
€37.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€20.98 €29.99
Paperback
€37.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

NGINX HTTP Server

Downloading and Installing NGINX

NGINX (pronounced engine-x) has become the leader among web servers ever since it came out 20 years ago. Back in 2004, its main goal was to outperform Apache, and today, NGINX is outperforming every web server when it comes to high-traffic websites or security. Throughout this book, we will discover and learn how to use NGINX, step by step. We will cover many subjects to have a configuration tailored to everyone’s needs.

In this first chapter, we will proceed with the necessary steps toward establishing a functional setup of NGINX. This moment is crucial for the smooth functioning of your web server—there are some required libraries and tools for installing the web server, some parameters that you will have to decide upon when compiling the binaries, and there may also be some configuration changes to perform on your system.

By the end of this chapter, you will have installed NGINX either through a public repository or by compiling...

Installing NGINX via package managers

The quickest, and easiest, way to install NGINX is to simply use your OS-provided version. Most of the time, these are kept fairly updated; however, for some Linux distributions focusing on stability, you may only have older versions of NGINX available. Sometimes, your Linux distribution may provide multiple versions of NGINX with different compile flags.

In general, before embarking on a more complex journey, we should check whether we can use the easy solution. For Red Hat Linux-based operating systems, we need to enable the EPEL repo first and then do the same:

yum install epel-release
yum search nginx
yum info PACKAGE_NAME
yum install PACKAGE_NAME

For a Debian-based operating system, we first find the NGINX compiles available and then get the information for the one we want:

apt-cache search nginx
apt-cache show PACKAGE_NAME
apt install PACKAGE_NAME

If the version provided is current enough, then you’re ready to configure...

Compiling NGINX from source

There are situations where compiling NGINX from source is preferable. It gives us the most flexibility regarding modules, so we can customize better for our intended usage. For example, we could compile a very lean version for embedded hardware.

Additionally, we can make sure we use the latest version of NGINX and have all new features available to us. Keep in mind, though, that when installing software from source, you are responsible for keeping it updated. NGINX, just like every other piece of software, sometimes finds security issues that it needs to address. An OS package is much easier to update than a source installation but, so long as you’re aware of the need to maintain it yourself, there is absolutely no problem.

Depending on the optional modules that you select at compile time, you will perhaps need different prerequisites. We will guide you through the process of installing the most common ones, such as GCC, PCRE, zlib, and OpenSSL...

Downloading and compiling the NGINX source code

This approach to the download process will lead us to discover the various resources at the disposal of server administrators, websites, communities, and wikis all relating to NGINX. We will also quickly discuss the different version branches available to you, and eventually, select the most appropriate one for your setup.

Websites and resources

Although NGINX is a relatively new and growing project, there are already a good number of resources available on the World Wide Web (WWW) and an active community of administrators and developers.

The official website, which is https://nginx.org/, currently serves as an official documentation reference and provides links from which to download the latest version of the application source code and binaries. A wiki is also available at https://www.nginx.com/resources/wiki/ and offers a wide selection of additional resources such as installation guides for various operating systems, tutorials...

Exploring the options for configuring the compilation

There are usually three steps when building an application from source—configuration, compilation, and installation. The configuration step allows you to select a number of options that will not be editable after the program is built, as it has a direct impact on the project binaries. Consequently, it is a very important stage that you need to follow carefully if you want to avoid surprises later, such as the lack of a specific module or files being located in a random folder.

The process consists of appending certain switches to the configure script that comes with the source code. We will discover the three types of switches that you can activate, but let us first study the easiest way to proceed.

The easy way

If, for some reason, you do not want to bother with the configuration step, such as for testing purposes or simply because you will be recompiling the application in the future, you may simply use the configure...

Controlling the NGINX service

At this stage, you should have successfully built and installed NGINX. The default location for the output files is /usr/local/nginx, so we will be basing future examples using this path to start, stop, run at boot, and keep an eye on the NGINX status using a daemon.

Daemons and services

The next step is obviously to execute NGINX. However, before doing so, it’s important to understand the nature of this application. There are two types of computer applications—those that require immediate user input, thus running in the foreground, and those that do not, thus running in the background. NGINX is of the latter type, often referred to as daemon. Daemon names usually come with a trailing d and a couple of examples can be mentioned here—httpd (the HTTP server daemon) is the name given to Apache under several Linux distributions, and named is the name server daemon. cron is the task scheduler—although, as you will notice, it...

Adding NGINX as a system service

In this section, we will create a script that will transform the NGINX daemon into an actual system service. This will result in mainly two outcomes—the daemon will be controllable using standard commands and, more importantly, it will automatically be launched on system startup and stopped on system shutdown.

systemd unit file

Most Linux-based operating systems to date use a systemd-style service file. Debian, Ubuntu, RHEL, and centOS all use systemd nowadays; therefore, this service file should work on any popular linux distribution. There is other init software, such as System V and OpenRC; however, we will stick with the more popular and most supported init.

In this example, we will be using the NGINX service file provided by the official NGINX website:

  1. Create a file by using the following command:
    nano /etc/systemd/system/nginx.service
Figure 1.3: Default systemd service file for Nginx

Figure 1.3: Default systemd service file for Nginx

Note...

A quick overview of the possibilities offered by NGINX Plus

As of mid-2013, NGINX, Inc., the company behind the NGINX project, also offers a paid subscription called NGINX Plus. The announcement came as a surprise for the open source community but several companies quickly jumped on the bandwagon and reported amazing improvements in terms of performance and scalability.

NGINX, Inc., the high-performance web company, today announced the availability of NGINX Plus, a fully-supported version of the popular NGINX open source software complete with advanced features and offered with professional services. The product is developed and supported by the core engineering team at Nginx Inc., and is available immediately on a subscription basis.

As business requirements continue to evolve rapidly, such as the shift to mobile and the explosion of dynamic content on the Web, CIOs are continuously looking for opportunities to increase application performance and development agility, while...

Summary

This chapter covered a number of critical steps. We first made sure that your system contained all the required components for compiling NGINX. We then proceeded to select the proper version branch for your usage – will you be using the stable version or a more advanced yet potentially less stable one? After downloading the source and configuring the compilation process by enabling or disabling features and modules such as SSL, GeoIP, and more, we compiled the application and installed it on the system in the directory of your choice. We created a unit service file and modified the system boot sequence to schedule the service to be started.

From this point on, NGINX is installed on your server and automatically starts with the system. Your web server is functional, though it does not yet answer the most basic functionality – serving a website. The first step toward hosting a website will be to prepare a suitable configuration file. The next chapter will cover...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Discover the potential of running NGINX in your environment
  • Run NGINX in harmony with your existing cloud infrastructure
  • Learn how to fine-tune and adjust NGINX's configuration for best performance
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

Explore the capabilities of NGINX, a robust HTTP server designed for handling high-traffic websites, with network scalability as its primary objective. Whether you’re a beginner or an experienced administrator, this NGINX book will guide you through the complete process of setting up this lightweight HTTP server, from quick and basic configurations to more detailed configurations tailored to your needs. Highlighting the latest version 1.25.2, featuring new features such as HTTP/3 and QUIC, this edition keeps you up to date with cutting-edge developments. This book is packed with a multitude of real-world examples, which will help you secure your infrastructure with automatic TLS certificates, expertly place NGINX in front of your existing applications, and do much more. From orchestration and Docker to bandwidth management, OpenResty, and NGINX Plus commercial features, you’ll get to grips with enhancing and optimizing your infrastructure or designing brand-new architecture. Moreover, this updated edition will show you how NGINX excels in cloud environments with guides on integrating NGINX with cloud services for deploying scalable architectures efficiently and securely. By the end of this book, you’ll be able to adapt and use a wide variety of NGINX implementations to tackle diverse challenges with confidence.

Who is this book for?

This book is for beginners and web administrators looking to master the powerful and secure NGINX HTTP server. Whether you want to replace your existing web server software or integrate a new tool to collaborate with applications that are already up and running, this book will help you achieve your goals. To get started, all you need is access to a Linux server and a basic understanding of web server concepts.

What you will learn

  • Install and configure a basic setup for NGINX and test it out
  • Discover the core functionality of the HTTP module as well as third-party modules
  • Understand how to set up NGINX to work with PHP, Python, and other applications
  • Optimize your architecture with threads or load balancing
  • Configure NGINX with orchestration and work in a Docker environment
  • Identify errors in configuration and grasp basic troubleshooting techniques

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 31, 2024
Length: 262 pages
Edition : 5th
Language : English
ISBN-13 : 9781835465752
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : May 31, 2024
Length: 262 pages
Edition : 5th
Language : English
ISBN-13 : 9781835465752
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 102.97 116.97 14.00 saved
Learn Ansible
€33.99
NGINX HTTP Server
€37.99
Solutions Architect's Handbook
€30.99 €44.99
Total 102.97 116.97 14.00 saved Stars icon

Table of Contents

16 Chapters
Part 1:Begin with NGINX Chevron down icon Chevron up icon
Chapter 1: Downloading and Installing NGINX Chevron down icon Chevron up icon
Chapter 2: Basic NGINX Configuration Chevron down icon Chevron up icon
Part 2: Dive into NGINX Chevron down icon Chevron up icon
Chapter 3: Exploring the HTTP Configuration Chevron down icon Chevron up icon
Chapter 4: Exploring Module Configuration in NGINX Chevron down icon Chevron up icon
Chapter 5: PHP and Python with NGINX Chevron down icon Chevron up icon
Chapter 6: NGINX as a Reverse Proxy Chevron down icon Chevron up icon
Part 3: NGINX in Action Chevron down icon Chevron up icon
Chapter 7: Introduction to Load Balancing and Optimization Chevron down icon Chevron up icon
Chapter 8: NGINX within a Cloud Infrastructure Chevron down icon Chevron up icon
Chapter 9: Fully Deploy, Manage, and Auto-Update NGINX with Ansible Chevron down icon Chevron up icon
Chapter 10: Case Studies Chevron down icon Chevron up icon
Chapter 11: Troubleshooting Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8
(4 Ratings)
5 star 75%
4 star 25%
3 star 0%
2 star 0%
1 star 0%
Yakov Shipilov Aug 28, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I highly recommend this book for anyone interested in learning about NGINX. The tutorials are easy to follow, even for beginners. The real-life examples helped me understand how to apply NGINX in different situations. The book is well-organized, starting from basic installation to advanced configurations. It’s a great resource if you want to improve your web server skills. Perfect for beginner DevOps engineers, system administrators, or anyone wanting to dive into web server management.
Amazon Verified review Amazon
Pablo Slomp Aug 07, 2024
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Feefo Verified review Feefo
Anslem John Jul 21, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Nginx is one the most used Webserver platforms to date. It can be used in a variety 0f ways: Load balancing, caching and even as a reverse proxy.This book gives you the foundation needed to understand and setup Nginx servers. The authors took their time and broke down the configuration syntax and setup strategies.Also complimenting the exposure of Nginx is the introduction to PHP and python applications, and fastcgi ,these go hand in hand and the book does a good job of explaining how they all work together.As mentioned earlier, Nginx can play the role of load balancing and reverse proxy and the book goes into details on setting up Nginx to function in those roles.Also the authors went into details on managing Nginx servers in a cloud environment using docker. If your new docker they have you covered.This is a great book for those who manage web infrastructure and use Nginx. You won’t regret it.
Amazon Verified review Amazon
Rogelio Carrera Jul 18, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I really enjoyed this book. It covers excellent examples and demonstrates in a technical manner just how powerful Nginx can be. The configuration examples with Django taught me multiple techniques to maintain security and keep my service running in optimal conditions.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.