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
AU$24.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8 (4 Ratings)
Paperback May 2024 262 pages 5th Edition
eBook
AU$38.99 AU$55.99
Paperback
AU$68.99
Subscription
Free Trial
Renews at AU$24.99p/m
Arrow left icon
Profile Icon Gabriel Ouiran Profile Icon Fjordvald Profile Icon Nedelcu
Arrow right icon
AU$24.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8 (4 Ratings)
Paperback May 2024 262 pages 5th Edition
eBook
AU$38.99 AU$55.99
Paperback
AU$68.99
Subscription
Free Trial
Renews at AU$24.99p/m
eBook
AU$38.99 AU$55.99
Paperback
AU$68.99
Subscription
Free Trial
Renews at AU$24.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $24.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781835469873
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $24.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
AU$24.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
AU$249.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 AU$5 each
Feature tick icon Exclusive print discounts
AU$349.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 AU$5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total AU$ 188.97 213.97 25.00 saved
Learn Ansible
AU$61.99
NGINX HTTP Server
AU$68.99
Solutions Architect's Handbook
AU$57.99 AU$82.99
Total AU$ 188.97 213.97 25.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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.