Table of Contents
Preface
Chapter 1: Downloading and Installing Nginx
Chapter 2: Basic Nginx Configuration
Chapter 3: HTTP Configuration
Chapter 4: Module Configuration
Chapter 5: PHP and Python with Nginx
Chapter 6: Apache and Nginx Together
Chapter 7: From Apache to Nginx
Appendix A: Directive Index
Appendix B: Module Reference
Appendix C: Troubleshooting
Index
- Chapter 1: Downloading and Installing Nginx
- Setting up the prerequisites
- GCC – 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
- Prerequisites 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
- What is an init script?
- Init script for Debian-based distributions
- Init script for Red Hat-based distributions
- Installing the script
- Debian-based distributions
- Red Hat-based distributions
- Summary
- Setting up the prerequisites
- Chapter 2: 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
- A configuration for your profile
- Understanding the default configuration
- Necessary adjustments
- Adapting to your hardware
- Testing your server
- Creating a test server
- Performance tests
- Httperf
- Autobench
- OpenWebLoad
- Upgrading Nginx gracefully
- Summary
- Configuration file syntax
- Chapter 3: 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
- 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
- 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
- Socket and host configuration
- 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:
- Location modifier
- Summary
- HTTP Core module
- Chapter 4: Module Configuration
- Rewrite module
- Reminder on regular expressions
- Purpose
- PCRE syntax
- Quantifiers
- Captures
- Internal requests
- error_page
- Rewrite
- Infinite loops
- Server Side Includes (SSI)
- Conditional structure
- Directives
- Common rewrite rules
- Performing a search
- User profile page
- Multiple parameters
- Wikipedia-like
- News website article
- Discussion board
- Reminder on regular expressions
- 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
- Content and encoding
- Empty GIF
- FLV and MP4
- HTTP headers
- Addition
- Substitution
- Gzip filter
- Gzip static
- 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
- Secure link
- Other miscellaneous modules
- Stub status
- Degradation
- Google-perftools
- WebDAV
- Third-party modules
- Website access and logging
- Summary
- Rewrite module
- Chapter 5: PHP and Python with Nginx
- Introduction to FastCGI
- Understanding the CGI mechanism
- Common Gateway Interface (CGI)
- Fast Common Gateway Interface (FastCGI)
- uWSGI and SCGI
- Main directives
- FastCGI caching
- Upstream blocks
- Module syntax
- Server directive
- 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
- Introduction to FastCGI
- Chapter 6: Apache and Nginx Together
- Nginx as reverse proxy
- Understanding the issue
- The reverse proxy mechanism
- Advantages and disadvantages of the mechanism
- Nginx proxy module
- Main directives
- Caching, buffering, and temporary files
- Limits, timeouts, and errors
- Other directives
- Variables
- 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
- Reconfiguring Apache
- Improving the reverse proxy architecture
- Forwarding the correct IP address
- SSL issues and solutions
- Server control panel issues
- Summary
- Nginx as reverse proxy
- Chapter 7: From Apache to Nginx
- Nginx versus Apache
- Features
- Core and functioning
- General functionality
- Flexibility and community
- Performance
- Usage
- Conclusion
- Features
- 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
- General remarks
- Summary
- Nginx versus Apache
- Appendix B: Module Reference
- Access
- Addition*
- Auth_basic module
- Autoindex
- Browser
- Charset
- Core
- DAV*
- Degradation*
- Empty GIF
- Events
- FastCGI
- FLV*
- Geo
- Geo IP*
- Google-perftools*
- Gzip
- Gzip Static*
- Headers
- HTTP Core
- Image Filter*
- Index
- Limit Conn
- Limit Requests
- Log
- Map
- Memcached
- MP4*
- Proxy
- Random index*
- Real IP*
- Referer
- Rewrite
- SCGI
- Secure Link*
- Split Clients
- SSI
- SSL*
- Stub status*
- Substitution*
- Upstream
- User ID
- uWSGI
- XSLT*
- Appendix C: Troubleshooting
- General tips on troubleshooting
- Checking access permissions
- Testing your configuration
- Have you reloaded the service?
- Checking logs
- Install issues
- The 403 Forbidden custom error page
- 400 Bad Request
- Location block priorities
- If block issues
- Inefficient statements
- Unexpected behavior
- Inefficient statements
- General tips on troubleshooting