ebook img

Nginx HTTP Server - PDF

341 Pages·2018·3.251 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Nginx HTTP Server -

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.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] 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. Contributors About the authors Martin Fjordvald is a 29-year-old Danish entrepreneur who started his company straight out of high school. Backed by a popular website, he became a jack of all trades having to deal with the business, programming, and marketing side of his business. The popularity of his website grew and so did the performance requirements of his code and servers. He got involved with the community project to document Nginx early on and has written several blog posts and wiki articles detailing how Nginx works. Special thanks to the entire Packt team for their patience during the course of writing this book. Clement Nedelcu was born in France and studied at UK, French, and Chinese universities. After teaching computer science, programming, and systems administration at several eastern Chinese universities, he worked as a technology consultant in France, specialized in the web and .NET software development as well as Linux server administration. Since 2005, he has also been administering a major network of websites in his spare time, which allowed him to discover Nginx. Clement now works as CTO. for a Hong-Kong-based company developing management software for schools. About the reviewer Amet Umerov works as a Linux system engineer with promising start-up. InsideDNA, which provides cloud-based genomics and data analytics to the biotechnology sector working on oncology drugs. Amet develops computing platforms for reproducible research in bioinformatics. Specifically, he builds and supports highly parallel, scalable, and stable computing environments for compute-intense analytics. He uses Nginx as the frontend for web applications and load balancers for Docker environments. I would like to express my gratitude to my family, friends, and colleagues. Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Table of Contents Preface 1 Chapter 1: Downloading and Installing Nginx 6 Installing via package managers 6 Nginx provided packages 7 Compiling from source 8 GNU Compiler Collection 9 The PCRE library 10 The zlib library 11 OpenSSL 11 Downloading Nginx 12 Websites and resources 12 Version branches 13 Features 14 Downloading and extracting 15 Configure options 16 The easy way 16 Path options 17 Prerequisite options 20 Module options 22 Modules enabled by default 22 Modules disabled by default 24 Miscellaneous options 26 Configuration examples 28 About the prefix switch 29 Regular HTTP and HTTPS servers 29 All modules enabled 30 Mail server proxy 30 Build configuration issues 31 Make sure you installed the prerequisites 31 Directories exist and are writable 32 Compiling and installing 32 Controlling the Nginx service 33 Daemons and services 33 User and group 33 Nginx command-line switches 34 Table of Contents Starting and stopping the daemon 34 Testing the configuration 35 Other switches 36 Adding Nginx as a system service 37 System V scripts 37 About init scripts 39 Init script for older Debian-based distributions 39 Init script for SystemD-based distributions 40 Installing the script 40 Debian-based distributions 41 Red Hat-based distributions 41 Nginx Plus 42 Summary 43 Chapter 2: Basic Nginx Configuration 44 Configuration file syntax 44 Configuration directives 45 Organization and inclusions 47 Directive blocks 49 Advanced language rules 50 Directives accept specific syntaxes 50 Diminutives in directive values 51 Variables 52 String values 53 Base module directives 53 What are base modules? 53 Nginx process architecture 54 Core module directives 55 Events module 61 Configuration module 64 Necessary adjustments 64 Testing your server 65 Creating a test server 66 Performance tests 67 Httperf 68 Autobench 69 OpenWebLoad 71 Upgrading Nginx gracefully 72 Summary 73 Chapter 3: HTTP Configuration 74 [ ii ] Table of Contents HTTP core module 74 Structure blocks 75 Module directives 77 Socket and host configuration 77 listen 77 server_name 78 server_name_in_redirect 79 server_names_hash_max_size 80 server_names_hash_bucket_size 80 port_in_redirect 80 absolute_redirect 80 tcp_nodelay 81 tcp_nopush 81 sendfile 81 sendfile_max_chunk 82 send_lowat 82 reset_timedout_connection 82 Paths and documents 83 root 83 alias 83 error_page 84 if_modified_since 84 index 85 recursive_error_pages 85 try_files 86 Client requests 87 keepalive_requests 87 keepalive_timeout 87 keepalive_disable 88 send_timeout 88 client_body_in_file_only 88 client_body_in_single_buffer 89 client_body_buffer_size 89 client_body_temp_path 89 client_body_timeout 90 client_header_buffer_size 90 client_header_timeout 90 client_max_body_size 91 large_client_header_buffers 91 lingering_time 91 lingering_timeout 92 lingering_close 92 ignore_invalid_headers 92 chunked_transfer_encoding 93 max_ranges 93 MIME types 93 [ iii ]

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.