logo资料库

Nginx HTTP Server Fourth Edition.pdf

第1页 / 共584页
第2页 / 共584页
第3页 / 共584页
第4页 / 共584页
第5页 / 共584页
第6页 / 共584页
第7页 / 共584页
第8页 / 共584页
资料共584页,剩余部分请下载后查看
Preface
Who this book is for
What this book covers
To get the most out of this book
Conventions used
Get in touch
Reviews
Downloading and Installing Nginx
Installing via package managers
Nginx provided packages
Compiling from source
GNU Compiler Collection
The PCRE library
The zlib library
OpenSSL
Downloading Nginx
Websites and resources
Version branches
Features
Downloading and extracting
Configure options
The easy way
Path options
Prerequisite options
Module options
Modules enabled by default
Modules disabled by default
Miscellaneous options
Configuration examples
About the prefix switch
Regular HTTP and HTTPS servers
All modules enabled
Mail server proxy
Build configuration issues
Make sure you installed the prerequisites
Directories exist and are writable
Compiling and installing
Controlling the Nginx service
Daemons and services
User and group
Nginx command-line switches
Starting and stopping the daemon
Testing the configuration
Other switches
Adding Nginx as a system service
System V scripts
About init scripts
Init script for older Debian-based distributions
Init script for SystemD-based distributions
Installing the script
Debian-based distributions
Red Hat-based distributions
Nginx Plus
Summary
Basic Nginx Configuration
Configuration file syntax
Configuration directives
Organization and inclusions
Directive blocks
Advanced language rules
Directives accept specific syntaxes
Diminutives in directive values
Variables
String values
Base module directives
What are base modules?
Nginx process architecture
Core module directives
Events module
Configuration module
Necessary adjustments
Testing your server
Creating a test server
Performance tests
Httperf
Autobench
OpenWebLoad
Upgrading Nginx gracefully
Summary
HTTP Configuration
HTTP core module
Structure blocks
Module directives
Socket and host configuration
listen
server_name
server_name_in_redirect
server_names_hash_max_size
server_names_hash_bucket_size
port_in_redirect
absolute_redirect
tcp_nodelay
tcp_nopush
sendfile
sendfile_max_chunk
send_lowat
reset_timedout_connection
Paths and documents
root
alias
error_page
if_modified_since
index
recursive_error_pages
try_files
Client requests
keepalive_requests
keepalive_timeout
keepalive_disable
send_timeout
client_body_in_file_only
client_body_in_single_buffer
client_body_buffer_size
client_body_temp_path
client_body_timeout
client_header_buffer_size
client_header_timeout
client_max_body_size
large_client_header_buffers
lingering_time
lingering_timeout
lingering_close
ignore_invalid_headers
chunked_transfer_encoding
max_ranges
MIME types
types
default_type
types_hash_max_size
types_hash_bucket_size
Limits and restrictions
limit_except
limit_rate
limit_rate_after
satisfy
internal
File processing and caching
disable_symlinks
directio
directio_alignment
open_file_cache
open_file_cache_errors
open_file_cache_min_uses
open_file_cache_valid
read_ahead
Other directives
log_not_found
log_subrequest
merge_slashes
msie_padding
msie_refresh
resolver
resolver_timeout
server_tokens
underscores_in_headers
variables_hash_max_size
variables_hash_bucket_size
post_action
Using HTTP/2
Module directives
http2_chunk_size
http2_body_preread_size
http2_idle_timeout
http2_max_concurrent_streams
http2_max_field_size
http2_max_header_size
http2_max_requests
http2_recv_buffer_size
http2_recv_timeout
Module variables
Module variables
Request headers
Response headers
Nginx generated
The location block
Location modifier
The = modifier
No modifier
The ~ modifier
The ~* modifier
The ^~ modifier
The @ modifier
Search order and priority
Case 1
Case 2
Case 3
Summary
Module Configuration
Rewrite module
Reminder on regular expressions
Purpose
PCRE syntax
Quantifiers
Captures
Internal requests
error_page
Rewrite
Infinite loops
Server Side Includes
Conditional structure
Directives
Common rewrite rules
Performing a search
User profile page
Multiple parameters
Wikipedia-like
News website article
Discussion board
SSI module
Module directives and variables
SSI commands
File includes
Working with variables
Conditional structure
Configuration
Additional modules
Website access and logging
Index
Autoindex
Random index
Log
Limits and restrictions
Auth_basic module
Access
Limit connections
Limit request
Auth request
Content and encoding
Empty GIF
FLV and MP4
HTTP headers
Addition
Substitution
Gzip filter
Gzip static
Gunzip filter
Charset filter
Memcached
Image filter
XSLT
About your visitors
Browser
Map
Geo
GeoIP
UserID filter
Referer
Real IP
Split clients
SSL and security
SSL
Setting up an SSL certificate
SSL stapling
Secure link
Other miscellaneous modules
Stub status
Degradation
Google-perftools
WebDAV
Third-party modules
Summary
PHP and Python with Nginx
Introduction to FastCGI
Understanding the CGI mechanism
Common Gateway Interface
Fast Common Gateway Interface (FastCGI)
uWSGI and SCGI
Main directives
FastCGI caching and buffering
PHP with Nginx
Architecture
PHP-FPM
Setting up PHP and PHP-FPM
Downloading and extracting
Requirements
Building PHP
Post-install configuration
Running and controlling
Nginx configuration
Python and Nginx
Django
Setting up Python and Django
Python
Django
Starting the FastCGI process manager
Nginx configuration
Summary
Nginx as an Application Server
The reverse proxy mechanism
Nginx proxy module
Main directives
Caching, buffering, and temporary files
Limits, timeouts, and errors
SSL-related directives
Other directives
Variables
Nginx and microservices
nginScript
Supported features
Unsupported features
Main directives
Handler example
Nginx Unit
Summary
Apache and Nginx Together
How Nginx and Apache benefit from each other
An example case
Configuring Apache and Nginx
Reconfiguring Apache
Configuration overview
Resetting the port number
Accepting local requests only
Configuring Nginx
Enabling proxy options
Separating content
Advanced configuration
Improving the reverse proxy architecture
Forwarding the correct IP address
SSL issues and solutions
Server control panel issues
Summary
From Apache to Nginx
Nginx versus Apache
Features
Core and functioning
General functionality
Flexibility and community
Performance
Usage
Conclusion
Porting your Apache configuration
Directives
Modules
Virtual hosts and configuration sections
Configuration sections
Creating a virtual host
.htaccess files
Reminder on Apache .htaccess files
Nginx equivalence
Rewrite rules
General remarks
On the location
On the syntax
RewriteRule
WordPress
MediaWiki
vBulletin
Summary
Introduction to Load Balancing and Optimization
Introduction to load balancing
Understanding the concept of load balancing
Session affinity
The upstream module
Request distribution mechanisms
Using Nginx as a TCP load balancer
The stream module
An example of MySQL load balancing
Thread pools and IO mechanisms
Relieving worker processes
AIO, Sendfile, and DirectIO
Summary
Case Studies
Deploying a WordPress site
Preparing your server and obtaining WordPress
System requirements
PHP configuration
MySQL configuration
Downloading and extracting WordPress
Nginx configuration
HTTP block
Server block
Location blocks
WordPress configuration
Securing communications with HTTPS
Self-signed certificates and certificate authorities
Obtaining your SSL certificate
Enabling HTTPS in your Nginx configuration
Setting up and testing HTTP/2
Creating your ownCloud drive
Getting ownCloud
Nginx configuration
Setting up a self-signed certificate
Summary
Troubleshooting
General tips on Nginx troubleshooting
Checking access permissions
Testing your configuration
Have you reloaded the service?
Checking logs
Installing a log parser
Install issues
The 403 forbidden custom error page
400 Bad Request
Truncated or invalid FastCGI responses
Location block priorities
If block issues
Inefficient statements
Unexpected behavior
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Nginx HTTP Server Fourth Edition Harness the power of Nginx to make the most of your infrastructure and serve pages faster than ever before Martin Fjordvald Clement Nedelcu
BIRMINGHAM - MUMBAI
Nginx HTTP Server Fourth Edition Copyright © 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Vijin Boricha Acquisition Editor: Shrilekha Inani Content Development Editor: Sharon Raj Technical Editor: Vishal K. Mewada Copy Editor: Safis Editing Project Coordinator: Virginia Dias Proofreader: Safis Editing Indexer: Pratik Shirodkar Production Coordinator: Shantanu Zagade First published: July 2010 Second edition: July 2013 Third edition: November 2015 Fourth edition: February 2018 Production reference: 1120218 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78862-355-1 www.packtpub.com
To my wife Richole Huang, for her love, patience, and understanding throughout our marriage.
mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content
PacktPub.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.P acktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
分享到:
收藏