0%

Book Description

Customize and regulate the robust Nginx web server, and write your own Nginx modules efficiently

  • Install Nginx from its source on multiple platforms
  • Become acquainted with core Nginx modules and their configuration options
  • Explore optional and third party module extensions along with configuration directives

In Detail

Companies can solve significant scaling issues thanks to switching their web platforms to Nginx. A popular web server for building web infrastructure, Nginx transparently and effectively enables the growth of the largest sites on the Internet today, on top of being free and open source.

This book is a practical reference providing you with everything you need to know about Nginx module extensions. You will learn how to write powerful and flexible configuration files and your own modules, as well as gaining knowledge about Nginx’s modular architecture, available modules, and their intricate details.

Nginx Module Extension starts by teaching you to compile the Nginx source on multiple platforms. Then you will learn the synopsis, directives, and practical examples of the core, optional, and third party Nginx modules before familiarizing yourself with Nginx internals, enabling you to write custom modules.

You will learn about the flexibility of the Nginx configuration and how to enable and disable various options while building from the source. You will learn to customize the Main and Events module to fine-tune the web server performance, and you will also learn about standard and optional HTTP modules like GeoIP, Gzip, Access Control, and using SSL, along with an exploration of PostgreSQL, MySQL, and Memcached modules. Finally you will learn internals like module chaining and will see sample code and a line-by-line walkthrough demonstrating how to write your own module.

Table of Contents

  1. Nginx Module Extension
    1. Table of Contents
    2. Nginx Module Extension
    3. Credits
    4. About the Author
    5. About the Reviewer
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Errata
        2. Piracy
        3. Questions
    8. 1. Installing Nginx Core and Modules from Source
      1. Installing binary distribution
        1. Red Hat, Fedora, and CentOS
        2. Official Debian/Ubuntu packages
        3. FreeBSD
        4. OpenBSD
        5. Official Win32 binaries
      2. Installing source distribution
        1. Nginx library dependencies
        2. Configuring options
          1. Files and permissions
          2. The Event loop
          3. Optional modules
          4. Compilation controls
          5. Example
          6. The Custom module
          7. Debugging
        3. Installing on other platforms
        4. Verifying your Nginx installation
      3. Summary
    9. 2. Configuring Core Modules
      1. Understanding the Main module
        1. Explaining directives
          1. daemon
          2. master_process
          3. timer_resolution
          4. pid
          5. lock_file
          6. worker_processes
          7. debug_points
          8. user
          9. worker_priority
          10. worker_cpu_affinity
          11. worker_rlimit_nofile
          12. worker_rlimit_core
          13. worker_rlimit_sigpending
          14. working_directory
          15. env
      2. Understanding the Events module
        1. Explaining directives
          1. accept_mutex
          2. accept_mutex_delay
          3. debug_connection
          4. devpoll_changes and devpoll_events
          5. kqueue_changes and kqueue_events
          6. epoll_events
          7. multi_accept
          8. rtsig_signo
          9. rtsig_overflow_events, rtsig_overflow_test, and rtsig_overflow_threshold
          10. use
          11. worker_connections
      3. Summary
    10. 3. Installing and Configuring HTTP Modules
      1. Standard HTTP modules
        1. The core module (HttpCoreModule)
        2. Explaining directives
          1. server
          2. server_name
            1. listen
              1. SSL
              2. default_server
            2. location
            3. server_names_hash_bucket_size
            4. server_names_hash_max_size
            5. tcp_nodelay/tcp_nopush
            6. sendfile
            7. sendfile_max_chunk
            8. root
            9. resolver/resolver_timeout
            10. aio
            11. alias
            12. error_page
            13. keepalive_disable, keepalive_timeout, and keepalive_requests
        3. Controlling access (HttpAccessModule)
        4. Authenticating users (HttpBasicAuthModule)
          1. Explaining directives
            1. auth_basic
            2. auth_basic_user_file
        5. Load balancing (HttpUpstreamModule)
          1. Explaining directives
            1. ip_hash
            2. server
            3. upstream
        6. Acting as a proxy (HttpProxyModule)
          1. Explaining directives
            1. proxy_pass
            2. proxy_pass_header
            3. proxy_connect_timeout
            4. proxy_next_upstream
            5. proxy_redirect
            6. proxy_set_header
            7. proxy_store
            8. proxy_cache
        7. Compressing content (HttpGzipModule)
          1. Explaining directives
            1. gzip
            2. gzip_buffers
            3. gzip_comp_level
            4. gzip_disable
            5. gzip_http_version
            6. gzip_min_length
            7. gzip_proxied
            8. gzip_types
        8. Controlling logging (HttpLogModule)
          1. Explaining directives
            1. access_log
            2. log_format
        9. Setting response headers (HttpHeadersModule)
          1. Explaining directives
            1. add_header
            2. expires
        10. Rewriting requests (HttpRewriteModule)
          1. Explaining directives
            1. break
            2. if
            3. return
            4. rewrite
            5. rewrite_log
            6. set
            7. uninitialized_variable_warn
        11. Interacting with FastCGI (HttpFastcgiModule)
        12. Simple caching (HttpMemcachedModule)
          1. Explaining directives
            1. memcached_pass
            2. memcached_connect_timeout
            3. memcached_read_timeout
            4. memcached_send_timeout
            5. memcached_buffer_size
            6. memcached_next_upstream
        13. Limiting requests (HttpLimitReqModule)
          1. Explaining directives
            1. limit_req
            2. limit_req_log_level
            3. limit_req_zone
        14. Limiting connections (HttpLimitConnModule)
          1. Explaining directives
            1. limit_conn
            2. limit_conn_zone
            3. limit_conn_log_level
            4. limit_conn_status
      2. Summary
    11. 4. Installing Third-party Modules
      1. Compiling third-party modules
        1. Communicating with PostgreSQL (ngx_postgres)
          1. Explaining directives
            1. postgres_server
            2. postgres_keepalive
            3. postgres_pass
            4. postgres_query
            5. postgres_rewrite
            6. postgres_output
            7. postgres_set
            8. postgres_escape
            9. postgres_connect_timeout
            10. postgres_result_timeout
        2. Communicating with MySQL and drizzle (drizzle-nginx)
          1. Explaining directives
            1. drizzle_server
            2. drizzle_keepalive
            3. drizzle_query
            4. drizzle_pass
            5. drizzle_connect_timeout
            6. drizzle_send_query_timeout
            7. drizzle_recv_cols_timeout
            8. drizzle_recv_rows_timeout
            9. drizzle_buffer_size
            10. drizzle_module_header
        3. Digest Authentication (ngx_http_auth_digest)
          1. Explaining directives
            1. auth_digest
            2. auth_digest_user_file
            3. auth_digest_timeout
            4. auth_digest_expires
            5. auth_digest_replays
            6. auth_digest_shm_size
        4. Speeding up web pages (ngx_pagespeed)
          1. Configuring handlers
        5. Lua scripting (ngx_lua)
          1. Explaining directives
            1. lua_package_path
            2. set_by_lua or set_by_lua_file
            3. content_by_lua or content_by_lua_file
            4. rewrite_by_lua or rewrite_by_lua_file
            5. access_by_lua or access_by_lua_file
        6. Reverse IP lookup using the GeoIP module (ngx_http_geoip_module)
          1. Explaining directives
            1. geoip_country
            2. geoip_city
            3. geoip_org
            4. geoip_proxy
            5. geoip_proxy_recursive
        7. Doing healthchecks
          1. ngx_http_healthcheck_module
          2. Explaining directives
            1. healthcheck_enabled
            2. healthcheck_delay
            3. healthcheck_timeout
            4. healthcheck_failcount
            5. healthcheck_send
            6. healthcheck_expected
            7. healthcheck_buffer
          3. Load balancing
            1. Consistent hashing
            2. Least busy
            3. Configuration variable hashing
      2. Summary
    12. 5. Creating Your Own Module
      1. Nginx module delegation
        1. Handlers
        2. Load balancers
        3. Filters
          1. Order of execution
      2. The extended "Hello world" module
        1. Writing and compiling a module
          1. The "Hello world" source code
        2. Components of the Nginx module
          1. Module configuration structures
          2. Module directives
          3. The module context
            1. create_loc_conf
            2. merge_loc_conf
          4. The module definition
          5. The handler function
      3. Nginx Development Toolkit (NDK)
      4. Summary
    13. Index
3.133.126.199