NGINX HTTP Server: Harness the power of NGINX with a series of detailed tutorials and real-life examples. 5 Ed

NGINX HTTP Server: Harness the power of NGINX with a series of detailed tutorials and real-life examples. 5 Ed

NGINX HTTP Server: Harness the power of NGINX with a series of detailed tutorials and real-life examples. 5 Ed
Автор: FJordvaldMartin Bjerretoft , Nedelcu Clement , Ouiran Gabriel
Дата выхода: 2024
Издательство: Packt Publishing Limited
Количество страниц: 262
Размер файла: 2,8 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы  Дополнительные материалы 

Preface xiii
Part 1: Begin with NGINX
1
Downloading and Installing NGINX 3
Installing NGINX via package
managers 4
NGINX-provided packages 4
Compiling NGINX from source 5
Installing GNU Compiler Collection 6
The PCRE library 7
The zlib library 7
OpenSSL 8
Downloading and compiling the NGINX source code 8
Websites and resources 9
Version branches 10
Features 10
Downloading and extracting 11
Exploring the options for configuring the compilation 11
The easy way 12
Path options 12
Build configuration issues 13
Compiling and installing 14
Controlling the NGINX service 15
Daemons and services 15
Users and groups 15
NGINX command-line switches 16
Starting and stopping the daemon 16
Testing the configuration 17
Other switches 18
Adding NGINX as a system service 18
systemd unit file 18
Handling system errors 20
A quick overview of the possibilities offered by NGINX Plus 20
Summary 21
2
Basic NGINX Configuration 23
Delving into the configuration file
syntax 23
Configuration directives 24
Organization and inclusions 26
Directive blocks 27
Advanced language rules 29
Looking at the base module directives 31
What are base modules? 31
NGINX process architecture 31
Core module directives 32
The events module 38
Configuration module 40
Necessary adjustments 40
Testing your server 41
Creating a test server 41
Upgrading NGINX gracefully 43
Summary 43
Part 2: Dive into NGINX
3
Exploring the HTTP Configuration 47
An introduction to the HTTP core
module and its three new blocks 47
Exploring the HTTP core module
directives 49
Socket and host configuration 50
Paths and documents 53
Client requests 57
MIME types 62
Limits and restrictions 64
File processing and caching 67
Other directives 69
Exploring the directives of HTTP/2 73
http2_chunk_size 74
http2_body_preread_size 74
http2_idle_timeout 74
http2_max_concurrent_streams 74
http2_max_field_size 74
http2_max_header_size 75
http2_max_requests 75
http2_recv_buffer_size 75
http2_recv_timeout 75
Module variables 76
Exploring the variables introduced
by the HTTP core module 76
Request headers 76
Response headers 77
NGINX-generated headers 78
Understanding and exploring the
location block 80
Location modifier 80
Search order and priority 83
Summary 86
4
Exploring Module Configuration in NGINX 87
Exploring the Rewrite module 87
Reminder of regular expressions 88
Internal requests 93
Conditional structure 98
Directives 100
Common rewrite rules 103
Looking at some additional modules 105
Website access and logging 105
Limits and restrictions 109
Content and encoding 113
About your visitors 125
SSL and security 131
Other miscellaneous and optional modules 136
Summary 138
5
PHP and Python with NGINX 139
Introduction to FastCGI
technologies 139
Understanding the CGI mechanism 140
CGI 141
FastCGI 142
uWSGI and SCGI 143
Main directives 144
FastCGI caching and buffering 150
PHP with NGINX 151
Architecture 152
PHP-FPM 152
Setting up PHP and PHP-FPM 152
NGINX configuration 154
Python and NGINX 155
Django 155
Setting up Python and Django 156
NGINX configuration 157
Summary 158
6
NGINX as a Reverse Proxy 159
Exploring the reverse proxy
mechanism 159
Exploring the NGINX proxy module 160
Main directives 161
Caching, buffering, and temporary files 164
Limits, timeouts, and errors 168
Other directives 170
Variables 172
Looking at NGINX and
microservices 172
Summary 173
Part 3: NGINX in Action
7
Introduction to Load Balancing and Optimization 177
Introducing load balancing 177
Understanding the concept of load balancing 178
Session affinity 179
The upstream module 180
Request distribution mechanisms 182
Using NGINX as a TCP/UDP load
balancer 183
The stream module 184
An example of MySQL load balancing 184
Exploring thread pools and I/O
mechanisms 185
Relieving worker processes 185
AIO, Sendfile, and DirectIO 186
Summary 187
8
NGINX within a Cloud Infrastructure 189
Understanding cloud infrastructure 190
The traditional approach 190
The cloud approach 190
Using Docker 192
Installing Docker 192
Your first Docker container 192
Simplifying with Docker Compose 193
Setting up NGINX inside Docker 194
Integrating PHP with NGINX using Docker
Compose 195
Setting up NGINX inside Docker to
proxy host applications 197
Summary 198
9
Fully Deploy, Manage, and Auto-Update NGINX with Ansible 199
Understanding configuration
management 199
Running your first Ansible playbook 200
Setting up NGINX using Ansible 202
Setting up automatic updates using
Ansible 203
Summary 204
10
Case Studies 205
Exploring SSL Certificates and
HTTPS by default 206
Certificate Management with acme.sh 206
acme.sh and the DNS API 207
Issuing a signed certificate 208
Centralizing SSL Configuration with NGINX 208
Implementing HTTP/2 with SSL 209
Deploying a WordPress site 209
Preparing your server and obtaining
WordPress 209
NGINX configuration 212
WordPress configuration 215
Deploying Nextcloud 217
Getting Nextcloud 217
Summary 219
11
Troubleshooting 221
Looking at some general tips on
NGINX troubleshooting 221
Checking access permissions 222
Testing your configuration 222
Have you reloaded the service? 222
Checking logs 223
Installing a log parser 223
Troubleshooting install issues 225
Looking at the 403 forbidden custom
error page 226
Exploring 400 Bad Request 227
Looking at truncated or invalid
FastCGI responses 227
Exploring location block priorities 228
Looking at if block issues 228
Inefficient statements 228
Unexpected behavior 229
Summary 230
Index 231
Other Books You May Enjoy 240

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.

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

Who this book is 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.


Похожее:

Список отзывов:

Нет отзывов к книге.