nginxtra 1.0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -0
- data/bin/nginxtra +5 -0
- data/lib/nginxtra.rb +12 -0
- data/lib/nginxtra/action.rb +36 -0
- data/lib/nginxtra/actions/compile.rb +60 -0
- data/lib/nginxtra/actions/install.rb +99 -0
- data/lib/nginxtra/actions/reload.rb +14 -0
- data/lib/nginxtra/actions/restart.rb +15 -0
- data/lib/nginxtra/actions/start.rb +53 -0
- data/lib/nginxtra/actions/status.rb +31 -0
- data/lib/nginxtra/actions/stop.rb +14 -0
- data/lib/nginxtra/cli.rb +77 -0
- data/lib/nginxtra/config.rb +339 -0
- data/lib/nginxtra/error.rb +13 -0
- data/lib/nginxtra/status.rb +57 -0
- data/src/nginx/CHANGES +5630 -0
- data/src/nginx/CHANGES.ru +5716 -0
- data/src/nginx/LICENSE +25 -0
- data/src/nginx/README +3 -0
- data/src/nginx/auto/cc/acc +15 -0
- data/src/nginx/auto/cc/bcc +72 -0
- data/src/nginx/auto/cc/ccc +46 -0
- data/src/nginx/auto/cc/conf +189 -0
- data/src/nginx/auto/cc/gcc +183 -0
- data/src/nginx/auto/cc/icc +121 -0
- data/src/nginx/auto/cc/msvc +138 -0
- data/src/nginx/auto/cc/name +101 -0
- data/src/nginx/auto/cc/owc +104 -0
- data/src/nginx/auto/cc/sunc +158 -0
- data/src/nginx/auto/define +12 -0
- data/src/nginx/auto/endianess +45 -0
- data/src/nginx/auto/feature +123 -0
- data/src/nginx/auto/have +12 -0
- data/src/nginx/auto/have_headers +12 -0
- data/src/nginx/auto/headers +13 -0
- data/src/nginx/auto/include +61 -0
- data/src/nginx/auto/init +51 -0
- data/src/nginx/auto/install +184 -0
- data/src/nginx/auto/lib/conf +83 -0
- data/src/nginx/auto/lib/geoip/conf +79 -0
- data/src/nginx/auto/lib/google-perftools/conf +45 -0
- data/src/nginx/auto/lib/libatomic/conf +43 -0
- data/src/nginx/auto/lib/libatomic/make +14 -0
- data/src/nginx/auto/lib/libgd/conf +83 -0
- data/src/nginx/auto/lib/libxslt/conf +156 -0
- data/src/nginx/auto/lib/make +32 -0
- data/src/nginx/auto/lib/md5/conf +103 -0
- data/src/nginx/auto/lib/md5/make +96 -0
- data/src/nginx/auto/lib/md5/makefile.bcc +22 -0
- data/src/nginx/auto/lib/md5/makefile.msvc +22 -0
- data/src/nginx/auto/lib/md5/makefile.owc +11 -0
- data/src/nginx/auto/lib/openssl/conf +74 -0
- data/src/nginx/auto/lib/openssl/make +67 -0
- data/src/nginx/auto/lib/openssl/makefile.bcc +18 -0
- data/src/nginx/auto/lib/openssl/makefile.msvc +14 -0
- data/src/nginx/auto/lib/pcre/conf +180 -0
- data/src/nginx/auto/lib/pcre/make +64 -0
- data/src/nginx/auto/lib/pcre/makefile.bcc +26 -0
- data/src/nginx/auto/lib/pcre/makefile.msvc +22 -0
- data/src/nginx/auto/lib/pcre/makefile.owc +24 -0
- data/src/nginx/auto/lib/perl/conf +60 -0
- data/src/nginx/auto/lib/perl/make +36 -0
- data/src/nginx/auto/lib/sha1/conf +79 -0
- data/src/nginx/auto/lib/sha1/make +96 -0
- data/src/nginx/auto/lib/sha1/makefile.bcc +22 -0
- data/src/nginx/auto/lib/sha1/makefile.msvc +22 -0
- data/src/nginx/auto/lib/sha1/makefile.owc +11 -0
- data/src/nginx/auto/lib/test +40 -0
- data/src/nginx/auto/lib/zlib/conf +76 -0
- data/src/nginx/auto/lib/zlib/make +114 -0
- data/src/nginx/auto/lib/zlib/makefile.bcc +15 -0
- data/src/nginx/auto/lib/zlib/makefile.msvc +14 -0
- data/src/nginx/auto/lib/zlib/makefile.owc +14 -0
- data/src/nginx/auto/lib/zlib/patch.zlib.h +10 -0
- data/src/nginx/auto/make +417 -0
- data/src/nginx/auto/modules +479 -0
- data/src/nginx/auto/nohave +12 -0
- data/src/nginx/auto/options +490 -0
- data/src/nginx/auto/os/conf +105 -0
- data/src/nginx/auto/os/darwin +116 -0
- data/src/nginx/auto/os/freebsd +136 -0
- data/src/nginx/auto/os/linux +152 -0
- data/src/nginx/auto/os/solaris +60 -0
- data/src/nginx/auto/os/win32 +29 -0
- data/src/nginx/auto/sources +518 -0
- data/src/nginx/auto/stubs +8 -0
- data/src/nginx/auto/summary +114 -0
- data/src/nginx/auto/types/sizeof +83 -0
- data/src/nginx/auto/types/typedef +77 -0
- data/src/nginx/auto/types/uintptr_t +42 -0
- data/src/nginx/auto/types/value +12 -0
- data/src/nginx/auto/unix +719 -0
- data/src/nginx/conf/fastcgi.conf +24 -0
- data/src/nginx/conf/fastcgi_params +23 -0
- data/src/nginx/conf/koi-utf +109 -0
- data/src/nginx/conf/koi-win +103 -0
- data/src/nginx/conf/mime.types +80 -0
- data/src/nginx/conf/nginx.conf +118 -0
- data/src/nginx/conf/scgi_params +15 -0
- data/src/nginx/conf/uwsgi_params +15 -0
- data/src/nginx/conf/win-utf +126 -0
- data/src/nginx/configure +108 -0
- data/src/nginx/contrib/README +15 -0
- data/src/nginx/contrib/geo2nginx.pl +58 -0
- data/src/nginx/contrib/unicode2nginx/koi-utf +131 -0
- data/src/nginx/contrib/unicode2nginx/unicode-to-nginx.pl +45 -0
- data/src/nginx/contrib/unicode2nginx/win-utf +130 -0
- data/src/nginx/html/50x.html +18 -0
- data/src/nginx/html/index.html +8 -0
- data/src/nginx/man/nginx.8 +202 -0
- data/src/nginx/src/core/nginx.c +1333 -0
- data/src/nginx/src/core/nginx.h +20 -0
- data/src/nginx/src/core/ngx_array.c +147 -0
- data/src/nginx/src/core/ngx_array.h +53 -0
- data/src/nginx/src/core/ngx_buf.c +218 -0
- data/src/nginx/src/core/ngx_buf.h +162 -0
- data/src/nginx/src/core/ngx_conf_file.c +1506 -0
- data/src/nginx/src/core/ngx_conf_file.h +348 -0
- data/src/nginx/src/core/ngx_config.h +134 -0
- data/src/nginx/src/core/ngx_connection.c +1074 -0
- data/src/nginx/src/core/ngx_connection.h +195 -0
- data/src/nginx/src/core/ngx_core.h +95 -0
- data/src/nginx/src/core/ngx_cpuinfo.c +139 -0
- data/src/nginx/src/core/ngx_crc.h +39 -0
- data/src/nginx/src/core/ngx_crc32.c +129 -0
- data/src/nginx/src/core/ngx_crc32.h +79 -0
- data/src/nginx/src/core/ngx_crypt.c +238 -0
- data/src/nginx/src/core/ngx_crypt.h +20 -0
- data/src/nginx/src/core/ngx_cycle.c +1379 -0
- data/src/nginx/src/core/ngx_cycle.h +142 -0
- data/src/nginx/src/core/ngx_file.c +993 -0
- data/src/nginx/src/core/ngx_file.h +151 -0
- data/src/nginx/src/core/ngx_hash.c +976 -0
- data/src/nginx/src/core/ngx_hash.h +122 -0
- data/src/nginx/src/core/ngx_inet.c +1008 -0
- data/src/nginx/src/core/ngx_inet.h +120 -0
- data/src/nginx/src/core/ngx_list.c +71 -0
- data/src/nginx/src/core/ngx_list.h +83 -0
- data/src/nginx/src/core/ngx_log.c +459 -0
- data/src/nginx/src/core/ngx_log.h +250 -0
- data/src/nginx/src/core/ngx_md5.c +289 -0
- data/src/nginx/src/core/ngx_md5.h +60 -0
- data/src/nginx/src/core/ngx_murmurhash.c +50 -0
- data/src/nginx/src/core/ngx_murmurhash.h +19 -0
- data/src/nginx/src/core/ngx_open_file_cache.c +882 -0
- data/src/nginx/src/core/ngx_open_file_cache.h +119 -0
- data/src/nginx/src/core/ngx_output_chain.c +673 -0
- data/src/nginx/src/core/ngx_palloc.c +433 -0
- data/src/nginx/src/core/ngx_palloc.h +95 -0
- data/src/nginx/src/core/ngx_parse.c +249 -0
- data/src/nginx/src/core/ngx_parse.h +24 -0
- data/src/nginx/src/core/ngx_queue.c +80 -0
- data/src/nginx/src/core/ngx_queue.h +112 -0
- data/src/nginx/src/core/ngx_radix_tree.c +291 -0
- data/src/nginx/src/core/ngx_radix_tree.h +46 -0
- data/src/nginx/src/core/ngx_rbtree.c +383 -0
- data/src/nginx/src/core/ngx_rbtree.h +84 -0
- data/src/nginx/src/core/ngx_regex.c +206 -0
- data/src/nginx/src/core/ngx_regex.h +56 -0
- data/src/nginx/src/core/ngx_resolver.c +2201 -0
- data/src/nginx/src/core/ngx_resolver.h +149 -0
- data/src/nginx/src/core/ngx_sha1.h +31 -0
- data/src/nginx/src/core/ngx_shmtx.c +284 -0
- data/src/nginx/src/core/ngx_shmtx.h +38 -0
- data/src/nginx/src/core/ngx_slab.c +701 -0
- data/src/nginx/src/core/ngx_slab.h +54 -0
- data/src/nginx/src/core/ngx_spinlock.c +53 -0
- data/src/nginx/src/core/ngx_string.c +1837 -0
- data/src/nginx/src/core/ngx_string.h +231 -0
- data/src/nginx/src/core/ngx_times.c +407 -0
- data/src/nginx/src/core/ngx_times.h +51 -0
- data/src/nginx/src/event/modules/ngx_aio_module.c +171 -0
- data/src/nginx/src/event/modules/ngx_devpoll_module.c +569 -0
- data/src/nginx/src/event/modules/ngx_epoll_module.c +833 -0
- data/src/nginx/src/event/modules/ngx_eventport_module.c +602 -0
- data/src/nginx/src/event/modules/ngx_kqueue_module.c +785 -0
- data/src/nginx/src/event/modules/ngx_poll_module.c +443 -0
- data/src/nginx/src/event/modules/ngx_rtsig_module.c +735 -0
- data/src/nginx/src/event/modules/ngx_select_module.c +435 -0
- data/src/nginx/src/event/modules/ngx_win32_select_module.c +400 -0
- data/src/nginx/src/event/ngx_event.c +1275 -0
- data/src/nginx/src/event/ngx_event.h +573 -0
- data/src/nginx/src/event/ngx_event_accept.c +428 -0
- data/src/nginx/src/event/ngx_event_busy_lock.c +286 -0
- data/src/nginx/src/event/ngx_event_busy_lock.h +65 -0
- data/src/nginx/src/event/ngx_event_connect.c +258 -0
- data/src/nginx/src/event/ngx_event_connect.h +76 -0
- data/src/nginx/src/event/ngx_event_mutex.c +70 -0
- data/src/nginx/src/event/ngx_event_openssl.c +2382 -0
- data/src/nginx/src/event/ngx_event_openssl.h +162 -0
- data/src/nginx/src/event/ngx_event_pipe.c +996 -0
- data/src/nginx/src/event/ngx_event_pipe.h +95 -0
- data/src/nginx/src/event/ngx_event_posted.c +173 -0
- data/src/nginx/src/event/ngx_event_posted.h +75 -0
- data/src/nginx/src/event/ngx_event_timer.c +159 -0
- data/src/nginx/src/event/ngx_event_timer.h +102 -0
- data/src/nginx/src/http/modules/ngx_http_access_module.c +384 -0
- data/src/nginx/src/http/modules/ngx_http_addition_filter_module.c +250 -0
- data/src/nginx/src/http/modules/ngx_http_auth_basic_module.c +478 -0
- data/src/nginx/src/http/modules/ngx_http_autoindex_module.c +701 -0
- data/src/nginx/src/http/modules/ngx_http_browser_module.c +713 -0
- data/src/nginx/src/http/modules/ngx_http_charset_filter_module.c +1681 -0
- data/src/nginx/src/http/modules/ngx_http_chunked_filter_module.c +242 -0
- data/src/nginx/src/http/modules/ngx_http_dav_module.c +1141 -0
- data/src/nginx/src/http/modules/ngx_http_degradation_module.c +243 -0
- data/src/nginx/src/http/modules/ngx_http_empty_gif_module.c +140 -0
- data/src/nginx/src/http/modules/ngx_http_fastcgi_module.c +2916 -0
- data/src/nginx/src/http/modules/ngx_http_flv_module.c +254 -0
- data/src/nginx/src/http/modules/ngx_http_geo_module.c +1441 -0
- data/src/nginx/src/http/modules/ngx_http_geoip_module.c +671 -0
- data/src/nginx/src/http/modules/ngx_http_gzip_filter_module.c +1206 -0
- data/src/nginx/src/http/modules/ngx_http_gzip_static_module.c +299 -0
- data/src/nginx/src/http/modules/ngx_http_headers_filter_module.c +616 -0
- data/src/nginx/src/http/modules/ngx_http_image_filter_module.c +1489 -0
- data/src/nginx/src/http/modules/ngx_http_index_module.c +516 -0
- data/src/nginx/src/http/modules/ngx_http_limit_req_module.c +809 -0
- data/src/nginx/src/http/modules/ngx_http_limit_zone_module.c +553 -0
- data/src/nginx/src/http/modules/ngx_http_log_module.c +1357 -0
- data/src/nginx/src/http/modules/ngx_http_map_module.c +575 -0
- data/src/nginx/src/http/modules/ngx_http_memcached_module.c +624 -0
- data/src/nginx/src/http/modules/ngx_http_mp4_module.c +3000 -0
- data/src/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +143 -0
- data/src/nginx/src/http/modules/ngx_http_proxy_module.c +2831 -0
- data/src/nginx/src/http/modules/ngx_http_random_index_module.c +317 -0
- data/src/nginx/src/http/modules/ngx_http_range_filter_module.c +855 -0
- data/src/nginx/src/http/modules/ngx_http_realip_module.c +476 -0
- data/src/nginx/src/http/modules/ngx_http_referer_module.c +613 -0
- data/src/nginx/src/http/modules/ngx_http_rewrite_module.c +1019 -0
- data/src/nginx/src/http/modules/ngx_http_scgi_module.c +1714 -0
- data/src/nginx/src/http/modules/ngx_http_secure_link_module.c +355 -0
- data/src/nginx/src/http/modules/ngx_http_split_clients_module.c +242 -0
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.c +2913 -0
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.h +114 -0
- data/src/nginx/src/http/modules/ngx_http_ssl_module.c +652 -0
- data/src/nginx/src/http/modules/ngx_http_ssl_module.h +52 -0
- data/src/nginx/src/http/modules/ngx_http_static_module.c +278 -0
- data/src/nginx/src/http/modules/ngx_http_stub_status_module.c +144 -0
- data/src/nginx/src/http/modules/ngx_http_sub_filter_module.c +716 -0
- data/src/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +237 -0
- data/src/nginx/src/http/modules/ngx_http_userid_filter_module.c +846 -0
- data/src/nginx/src/http/modules/ngx_http_uwsgi_module.c +1774 -0
- data/src/nginx/src/http/modules/ngx_http_xslt_filter_module.c +984 -0
- data/src/nginx/src/http/modules/perl/Makefile.PL +42 -0
- data/src/nginx/src/http/modules/perl/nginx.pm +137 -0
- data/src/nginx/src/http/modules/perl/nginx.xs +986 -0
- data/src/nginx/src/http/modules/perl/ngx_http_perl_module.c +1076 -0
- data/src/nginx/src/http/modules/perl/ngx_http_perl_module.h +67 -0
- data/src/nginx/src/http/modules/perl/typemap +3 -0
- data/src/nginx/src/http/ngx_http.c +2073 -0
- data/src/nginx/src/http/ngx_http.h +160 -0
- data/src/nginx/src/http/ngx_http_busy_lock.c +307 -0
- data/src/nginx/src/http/ngx_http_busy_lock.h +54 -0
- data/src/nginx/src/http/ngx_http_cache.h +148 -0
- data/src/nginx/src/http/ngx_http_config.h +75 -0
- data/src/nginx/src/http/ngx_http_copy_filter_module.c +300 -0
- data/src/nginx/src/http/ngx_http_core_module.c +4736 -0
- data/src/nginx/src/http/ngx_http_core_module.h +541 -0
- data/src/nginx/src/http/ngx_http_file_cache.c +1715 -0
- data/src/nginx/src/http/ngx_http_header_filter_module.c +623 -0
- data/src/nginx/src/http/ngx_http_parse.c +1734 -0
- data/src/nginx/src/http/ngx_http_parse_time.c +276 -0
- data/src/nginx/src/http/ngx_http_postpone_filter_module.c +178 -0
- data/src/nginx/src/http/ngx_http_request.c +3181 -0
- data/src/nginx/src/http/ngx_http_request.h +573 -0
- data/src/nginx/src/http/ngx_http_request_body.c +644 -0
- data/src/nginx/src/http/ngx_http_script.c +1752 -0
- data/src/nginx/src/http/ngx_http_script.h +257 -0
- data/src/nginx/src/http/ngx_http_special_response.c +789 -0
- data/src/nginx/src/http/ngx_http_upstream.c +4555 -0
- data/src/nginx/src/http/ngx_http_upstream.h +350 -0
- data/src/nginx/src/http/ngx_http_upstream_round_robin.c +791 -0
- data/src/nginx/src/http/ngx_http_upstream_round_robin.h +85 -0
- data/src/nginx/src/http/ngx_http_variables.c +2053 -0
- data/src/nginx/src/http/ngx_http_variables.h +115 -0
- data/src/nginx/src/http/ngx_http_write_filter_module.c +315 -0
- data/src/nginx/src/mail/ngx_mail.c +542 -0
- data/src/nginx/src/mail/ngx_mail.h +407 -0
- data/src/nginx/src/mail/ngx_mail_auth_http_module.c +1452 -0
- data/src/nginx/src/mail/ngx_mail_core_module.c +553 -0
- data/src/nginx/src/mail/ngx_mail_handler.c +773 -0
- data/src/nginx/src/mail/ngx_mail_imap_handler.c +457 -0
- data/src/nginx/src/mail/ngx_mail_imap_module.c +253 -0
- data/src/nginx/src/mail/ngx_mail_imap_module.h +39 -0
- data/src/nginx/src/mail/ngx_mail_parse.c +885 -0
- data/src/nginx/src/mail/ngx_mail_pop3_handler.c +500 -0
- data/src/nginx/src/mail/ngx_mail_pop3_module.c +264 -0
- data/src/nginx/src/mail/ngx_mail_pop3_module.h +38 -0
- data/src/nginx/src/mail/ngx_mail_proxy_module.c +1089 -0
- data/src/nginx/src/mail/ngx_mail_smtp_handler.c +872 -0
- data/src/nginx/src/mail/ngx_mail_smtp_module.c +308 -0
- data/src/nginx/src/mail/ngx_mail_smtp_module.h +45 -0
- data/src/nginx/src/mail/ngx_mail_ssl_module.c +491 -0
- data/src/nginx/src/mail/ngx_mail_ssl_module.h +52 -0
- data/src/nginx/src/misc/ngx_cpp_test_module.cpp +27 -0
- data/src/nginx/src/misc/ngx_google_perftools_module.c +126 -0
- data/src/nginx/src/os/unix/ngx_aio_read.c +109 -0
- data/src/nginx/src/os/unix/ngx_aio_read_chain.c +78 -0
- data/src/nginx/src/os/unix/ngx_aio_write.c +109 -0
- data/src/nginx/src/os/unix/ngx_aio_write_chain.c +100 -0
- data/src/nginx/src/os/unix/ngx_alloc.c +90 -0
- data/src/nginx/src/os/unix/ngx_alloc.h +45 -0
- data/src/nginx/src/os/unix/ngx_atomic.h +311 -0
- data/src/nginx/src/os/unix/ngx_channel.c +258 -0
- data/src/nginx/src/os/unix/ngx_channel.h +34 -0
- data/src/nginx/src/os/unix/ngx_daemon.c +69 -0
- data/src/nginx/src/os/unix/ngx_darwin.h +20 -0
- data/src/nginx/src/os/unix/ngx_darwin_config.h +96 -0
- data/src/nginx/src/os/unix/ngx_darwin_init.c +166 -0
- data/src/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +366 -0
- data/src/nginx/src/os/unix/ngx_errno.c +87 -0
- data/src/nginx/src/os/unix/ngx_errno.h +68 -0
- data/src/nginx/src/os/unix/ngx_file_aio_read.c +208 -0
- data/src/nginx/src/os/unix/ngx_files.c +566 -0
- data/src/nginx/src/os/unix/ngx_files.h +343 -0
- data/src/nginx/src/os/unix/ngx_freebsd.h +24 -0
- data/src/nginx/src/os/unix/ngx_freebsd_config.h +119 -0
- data/src/nginx/src/os/unix/ngx_freebsd_init.c +259 -0
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +756 -0
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +122 -0
- data/src/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +436 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_amd64.h +82 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_ppc.h +155 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_sparc64.h +82 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_x86.h +127 -0
- data/src/nginx/src/os/unix/ngx_linux.h +18 -0
- data/src/nginx/src/os/unix/ngx_linux_aio_read.c +137 -0
- data/src/nginx/src/os/unix/ngx_linux_config.h +117 -0
- data/src/nginx/src/os/unix/ngx_linux_init.c +91 -0
- data/src/nginx/src/os/unix/ngx_linux_sendfile_chain.c +378 -0
- data/src/nginx/src/os/unix/ngx_os.h +84 -0
- data/src/nginx/src/os/unix/ngx_posix_config.h +153 -0
- data/src/nginx/src/os/unix/ngx_posix_init.c +124 -0
- data/src/nginx/src/os/unix/ngx_process.c +590 -0
- data/src/nginx/src/os/unix/ngx_process.h +87 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.c +1390 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.h +61 -0
- data/src/nginx/src/os/unix/ngx_pthread_thread.c +278 -0
- data/src/nginx/src/os/unix/ngx_readv_chain.c +258 -0
- data/src/nginx/src/os/unix/ngx_recv.c +180 -0
- data/src/nginx/src/os/unix/ngx_send.c +73 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.c +135 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.h +52 -0
- data/src/nginx/src/os/unix/ngx_shmem.c +126 -0
- data/src/nginx/src/os/unix/ngx_shmem.h +29 -0
- data/src/nginx/src/os/unix/ngx_socket.c +116 -0
- data/src/nginx/src/os/unix/ngx_socket.h +64 -0
- data/src/nginx/src/os/unix/ngx_solaris.h +16 -0
- data/src/nginx/src/os/unix/ngx_solaris_config.h +107 -0
- data/src/nginx/src/os/unix/ngx_solaris_init.c +75 -0
- data/src/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +251 -0
- data/src/nginx/src/os/unix/ngx_sunpro_amd64.il +43 -0
- data/src/nginx/src/os/unix/ngx_sunpro_atomic_sparc64.h +61 -0
- data/src/nginx/src/os/unix/ngx_sunpro_sparc64.il +36 -0
- data/src/nginx/src/os/unix/ngx_sunpro_x86.il +44 -0
- data/src/nginx/src/os/unix/ngx_thread.h +128 -0
- data/src/nginx/src/os/unix/ngx_time.c +104 -0
- data/src/nginx/src/os/unix/ngx_time.h +66 -0
- data/src/nginx/src/os/unix/ngx_udp_recv.c +115 -0
- data/src/nginx/src/os/unix/ngx_user.c +109 -0
- data/src/nginx/src/os/unix/ngx_user.h +24 -0
- data/src/nginx/src/os/unix/ngx_writev_chain.c +181 -0
- data/src/nginx/src/os/unix/rfork_thread.S +73 -0
- metadata +419 -0
@@ -0,0 +1,1774 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Unbit S.a.s. 2009-2010
|
4
|
+
* Copyright (C) 2008 Manlio Perillo (manlio.perillo@gmail.com)
|
5
|
+
* Copyright (C) Igor Sysoev
|
6
|
+
* Copyright (C) Nginx, Inc.
|
7
|
+
*/
|
8
|
+
|
9
|
+
|
10
|
+
#include <ngx_config.h>
|
11
|
+
#include <ngx_core.h>
|
12
|
+
#include <ngx_http.h>
|
13
|
+
|
14
|
+
|
15
|
+
typedef struct {
|
16
|
+
ngx_http_upstream_conf_t upstream;
|
17
|
+
|
18
|
+
ngx_array_t *flushes;
|
19
|
+
ngx_array_t *params_len;
|
20
|
+
ngx_array_t *params;
|
21
|
+
ngx_array_t *params_source;
|
22
|
+
|
23
|
+
ngx_hash_t headers_hash;
|
24
|
+
ngx_uint_t header_params;
|
25
|
+
|
26
|
+
ngx_array_t *uwsgi_lengths;
|
27
|
+
ngx_array_t *uwsgi_values;
|
28
|
+
|
29
|
+
#if (NGX_HTTP_CACHE)
|
30
|
+
ngx_http_complex_value_t cache_key;
|
31
|
+
#endif
|
32
|
+
|
33
|
+
ngx_str_t uwsgi_string;
|
34
|
+
|
35
|
+
ngx_uint_t modifier1;
|
36
|
+
ngx_uint_t modifier2;
|
37
|
+
} ngx_http_uwsgi_loc_conf_t;
|
38
|
+
|
39
|
+
|
40
|
+
static ngx_int_t ngx_http_uwsgi_eval(ngx_http_request_t *r,
|
41
|
+
ngx_http_uwsgi_loc_conf_t *uwcf);
|
42
|
+
static ngx_int_t ngx_http_uwsgi_create_request(ngx_http_request_t *r);
|
43
|
+
static ngx_int_t ngx_http_uwsgi_reinit_request(ngx_http_request_t *r);
|
44
|
+
static ngx_int_t ngx_http_uwsgi_process_status_line(ngx_http_request_t *r);
|
45
|
+
static ngx_int_t ngx_http_uwsgi_process_header(ngx_http_request_t *r);
|
46
|
+
static ngx_int_t ngx_http_uwsgi_process_header(ngx_http_request_t *r);
|
47
|
+
static void ngx_http_uwsgi_abort_request(ngx_http_request_t *r);
|
48
|
+
static void ngx_http_uwsgi_finalize_request(ngx_http_request_t *r,
|
49
|
+
ngx_int_t rc);
|
50
|
+
|
51
|
+
static void *ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf);
|
52
|
+
static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
|
53
|
+
void *child);
|
54
|
+
static ngx_int_t ngx_http_uwsgi_merge_params(ngx_conf_t *cf,
|
55
|
+
ngx_http_uwsgi_loc_conf_t *conf, ngx_http_uwsgi_loc_conf_t *prev);
|
56
|
+
|
57
|
+
static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
58
|
+
void *conf);
|
59
|
+
static char *ngx_http_uwsgi_store(ngx_conf_t *cf, ngx_command_t *cmd,
|
60
|
+
void *conf);
|
61
|
+
|
62
|
+
#if (NGX_HTTP_CACHE)
|
63
|
+
static ngx_int_t ngx_http_uwsgi_create_key(ngx_http_request_t *r);
|
64
|
+
static char *ngx_http_uwsgi_cache(ngx_conf_t *cf, ngx_command_t *cmd,
|
65
|
+
void *conf);
|
66
|
+
static char *ngx_http_uwsgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd,
|
67
|
+
void *conf);
|
68
|
+
#endif
|
69
|
+
|
70
|
+
|
71
|
+
static ngx_conf_num_bounds_t ngx_http_uwsgi_modifier_bounds = {
|
72
|
+
ngx_conf_check_num_bounds, 0, 255
|
73
|
+
};
|
74
|
+
|
75
|
+
|
76
|
+
static ngx_conf_bitmask_t ngx_http_uwsgi_next_upstream_masks[] = {
|
77
|
+
{ ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR },
|
78
|
+
{ ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT },
|
79
|
+
{ ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER },
|
80
|
+
{ ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 },
|
81
|
+
{ ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
|
82
|
+
{ ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
|
83
|
+
{ ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
|
84
|
+
{ ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
|
85
|
+
{ ngx_null_string, 0 }
|
86
|
+
};
|
87
|
+
|
88
|
+
|
89
|
+
ngx_module_t ngx_http_uwsgi_module;
|
90
|
+
|
91
|
+
|
92
|
+
static ngx_command_t ngx_http_uwsgi_commands[] = {
|
93
|
+
|
94
|
+
{ ngx_string("uwsgi_pass"),
|
95
|
+
NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
|
96
|
+
ngx_http_uwsgi_pass,
|
97
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
98
|
+
0,
|
99
|
+
NULL },
|
100
|
+
|
101
|
+
{ ngx_string("uwsgi_modifier1"),
|
102
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
103
|
+
ngx_conf_set_num_slot,
|
104
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
105
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, modifier1),
|
106
|
+
&ngx_http_uwsgi_modifier_bounds },
|
107
|
+
|
108
|
+
{ ngx_string("uwsgi_modifier2"),
|
109
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
110
|
+
ngx_conf_set_num_slot,
|
111
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
112
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, modifier2),
|
113
|
+
&ngx_http_uwsgi_modifier_bounds },
|
114
|
+
|
115
|
+
{ ngx_string("uwsgi_store"),
|
116
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
117
|
+
ngx_http_uwsgi_store,
|
118
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
119
|
+
0,
|
120
|
+
NULL },
|
121
|
+
|
122
|
+
{ ngx_string("uwsgi_store_access"),
|
123
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,
|
124
|
+
ngx_conf_set_access_slot,
|
125
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
126
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.store_access),
|
127
|
+
NULL },
|
128
|
+
|
129
|
+
{ ngx_string("uwsgi_buffering"),
|
130
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
131
|
+
ngx_conf_set_flag_slot,
|
132
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
133
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.buffering),
|
134
|
+
NULL },
|
135
|
+
|
136
|
+
{ ngx_string("uwsgi_ignore_client_abort"),
|
137
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
138
|
+
ngx_conf_set_flag_slot,
|
139
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
140
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.ignore_client_abort),
|
141
|
+
NULL },
|
142
|
+
|
143
|
+
{ ngx_string("uwsgi_bind"),
|
144
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
145
|
+
ngx_http_upstream_bind_set_slot,
|
146
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
147
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.local),
|
148
|
+
NULL },
|
149
|
+
|
150
|
+
{ ngx_string("uwsgi_connect_timeout"),
|
151
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
152
|
+
ngx_conf_set_msec_slot,
|
153
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
154
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.connect_timeout),
|
155
|
+
NULL },
|
156
|
+
|
157
|
+
{ ngx_string("uwsgi_send_timeout"),
|
158
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
159
|
+
ngx_conf_set_msec_slot,
|
160
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
161
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.send_timeout),
|
162
|
+
NULL },
|
163
|
+
|
164
|
+
{ ngx_string("uwsgi_buffer_size"),
|
165
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
166
|
+
ngx_conf_set_size_slot,
|
167
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
168
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.buffer_size),
|
169
|
+
NULL },
|
170
|
+
|
171
|
+
{ ngx_string("uwsgi_pass_request_headers"),
|
172
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
173
|
+
ngx_conf_set_flag_slot,
|
174
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
175
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.pass_request_headers),
|
176
|
+
NULL },
|
177
|
+
|
178
|
+
{ ngx_string("uwsgi_pass_request_body"),
|
179
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
180
|
+
ngx_conf_set_flag_slot,
|
181
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
182
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.pass_request_body),
|
183
|
+
NULL },
|
184
|
+
|
185
|
+
{ ngx_string("uwsgi_intercept_errors"),
|
186
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
187
|
+
ngx_conf_set_flag_slot,
|
188
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
189
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.intercept_errors),
|
190
|
+
NULL },
|
191
|
+
|
192
|
+
{ ngx_string("uwsgi_read_timeout"),
|
193
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
194
|
+
ngx_conf_set_msec_slot,
|
195
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
196
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.read_timeout),
|
197
|
+
NULL },
|
198
|
+
|
199
|
+
{ ngx_string("uwsgi_buffers"),
|
200
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
|
201
|
+
ngx_conf_set_bufs_slot,
|
202
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
203
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.bufs),
|
204
|
+
NULL },
|
205
|
+
|
206
|
+
{ ngx_string("uwsgi_busy_buffers_size"),
|
207
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
208
|
+
ngx_conf_set_size_slot,
|
209
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
210
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.busy_buffers_size_conf),
|
211
|
+
NULL },
|
212
|
+
|
213
|
+
#if (NGX_HTTP_CACHE)
|
214
|
+
|
215
|
+
{ ngx_string("uwsgi_cache"),
|
216
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
217
|
+
ngx_http_uwsgi_cache,
|
218
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
219
|
+
0,
|
220
|
+
NULL },
|
221
|
+
|
222
|
+
{ ngx_string("uwsgi_cache_key"),
|
223
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
224
|
+
ngx_http_uwsgi_cache_key,
|
225
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
226
|
+
0,
|
227
|
+
NULL },
|
228
|
+
|
229
|
+
{ ngx_string("uwsgi_cache_path"),
|
230
|
+
NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE,
|
231
|
+
ngx_http_file_cache_set_slot,
|
232
|
+
0,
|
233
|
+
0,
|
234
|
+
&ngx_http_uwsgi_module },
|
235
|
+
|
236
|
+
{ ngx_string("uwsgi_cache_bypass"),
|
237
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
238
|
+
ngx_http_set_predicate_slot,
|
239
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
240
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_bypass),
|
241
|
+
NULL },
|
242
|
+
|
243
|
+
{ ngx_string("uwsgi_no_cache"),
|
244
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
245
|
+
ngx_http_set_predicate_slot,
|
246
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
247
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.no_cache),
|
248
|
+
NULL },
|
249
|
+
|
250
|
+
{ ngx_string("uwsgi_cache_valid"),
|
251
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
252
|
+
ngx_http_file_cache_valid_set_slot,
|
253
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
254
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_valid),
|
255
|
+
NULL },
|
256
|
+
|
257
|
+
{ ngx_string("uwsgi_cache_min_uses"),
|
258
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
259
|
+
ngx_conf_set_num_slot,
|
260
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
261
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_min_uses),
|
262
|
+
NULL },
|
263
|
+
|
264
|
+
{ ngx_string("uwsgi_cache_use_stale"),
|
265
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
266
|
+
ngx_conf_set_bitmask_slot,
|
267
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
268
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_use_stale),
|
269
|
+
&ngx_http_uwsgi_next_upstream_masks },
|
270
|
+
|
271
|
+
{ ngx_string("uwsgi_cache_methods"),
|
272
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
273
|
+
ngx_conf_set_bitmask_slot,
|
274
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
275
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_methods),
|
276
|
+
&ngx_http_upstream_cache_method_mask },
|
277
|
+
|
278
|
+
#endif
|
279
|
+
|
280
|
+
{ ngx_string("uwsgi_temp_path"),
|
281
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
|
282
|
+
ngx_conf_set_path_slot,
|
283
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
284
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.temp_path),
|
285
|
+
NULL },
|
286
|
+
|
287
|
+
{ ngx_string("uwsgi_max_temp_file_size"),
|
288
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
289
|
+
ngx_conf_set_size_slot,
|
290
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
291
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.max_temp_file_size_conf),
|
292
|
+
NULL },
|
293
|
+
|
294
|
+
{ ngx_string("uwsgi_temp_file_write_size"),
|
295
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
296
|
+
ngx_conf_set_size_slot,
|
297
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
298
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.temp_file_write_size_conf),
|
299
|
+
NULL },
|
300
|
+
|
301
|
+
{ ngx_string("uwsgi_next_upstream"),
|
302
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
303
|
+
ngx_conf_set_bitmask_slot,
|
304
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
305
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.next_upstream),
|
306
|
+
&ngx_http_uwsgi_next_upstream_masks },
|
307
|
+
|
308
|
+
{ ngx_string("uwsgi_param"),
|
309
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
|
310
|
+
ngx_conf_set_keyval_slot,
|
311
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
312
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, params_source),
|
313
|
+
NULL },
|
314
|
+
|
315
|
+
{ ngx_string("uwsgi_string"),
|
316
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
317
|
+
ngx_conf_set_str_slot,
|
318
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
319
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, uwsgi_string),
|
320
|
+
NULL },
|
321
|
+
|
322
|
+
{ ngx_string("uwsgi_pass_header"),
|
323
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
324
|
+
ngx_conf_set_str_array_slot,
|
325
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
326
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.pass_headers),
|
327
|
+
NULL },
|
328
|
+
|
329
|
+
{ ngx_string("uwsgi_hide_header"),
|
330
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
331
|
+
ngx_conf_set_str_array_slot,
|
332
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
333
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.hide_headers),
|
334
|
+
NULL },
|
335
|
+
|
336
|
+
{ ngx_string("uwsgi_ignore_headers"),
|
337
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
338
|
+
ngx_conf_set_bitmask_slot,
|
339
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
340
|
+
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.ignore_headers),
|
341
|
+
&ngx_http_upstream_ignore_headers_masks },
|
342
|
+
|
343
|
+
ngx_null_command
|
344
|
+
};
|
345
|
+
|
346
|
+
|
347
|
+
static ngx_http_module_t ngx_http_uwsgi_module_ctx = {
|
348
|
+
NULL, /* preconfiguration */
|
349
|
+
NULL, /* postconfiguration */
|
350
|
+
|
351
|
+
NULL, /* create main configuration */
|
352
|
+
NULL, /* init main configuration */
|
353
|
+
|
354
|
+
NULL, /* create server configuration */
|
355
|
+
NULL, /* merge server configuration */
|
356
|
+
|
357
|
+
ngx_http_uwsgi_create_loc_conf, /* create location configuration */
|
358
|
+
ngx_http_uwsgi_merge_loc_conf /* merge location configuration */
|
359
|
+
};
|
360
|
+
|
361
|
+
|
362
|
+
ngx_module_t ngx_http_uwsgi_module = {
|
363
|
+
NGX_MODULE_V1,
|
364
|
+
&ngx_http_uwsgi_module_ctx, /* module context */
|
365
|
+
ngx_http_uwsgi_commands, /* module directives */
|
366
|
+
NGX_HTTP_MODULE, /* module type */
|
367
|
+
NULL, /* init master */
|
368
|
+
NULL, /* init module */
|
369
|
+
NULL, /* init process */
|
370
|
+
NULL, /* init thread */
|
371
|
+
NULL, /* exit thread */
|
372
|
+
NULL, /* exit process */
|
373
|
+
NULL, /* exit master */
|
374
|
+
NGX_MODULE_V1_PADDING
|
375
|
+
};
|
376
|
+
|
377
|
+
|
378
|
+
static ngx_str_t ngx_http_uwsgi_hide_headers[] = {
|
379
|
+
ngx_string("X-Accel-Expires"),
|
380
|
+
ngx_string("X-Accel-Redirect"),
|
381
|
+
ngx_string("X-Accel-Limit-Rate"),
|
382
|
+
ngx_string("X-Accel-Buffering"),
|
383
|
+
ngx_string("X-Accel-Charset"),
|
384
|
+
ngx_null_string
|
385
|
+
};
|
386
|
+
|
387
|
+
|
388
|
+
#if (NGX_HTTP_CACHE)
|
389
|
+
|
390
|
+
static ngx_keyval_t ngx_http_uwsgi_cache_headers[] = {
|
391
|
+
{ ngx_string("HTTP_IF_MODIFIED_SINCE"), ngx_string("") },
|
392
|
+
{ ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") },
|
393
|
+
{ ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") },
|
394
|
+
{ ngx_string("HTTP_IF_MATCH"), ngx_string("") },
|
395
|
+
{ ngx_string("HTTP_RANGE"), ngx_string("") },
|
396
|
+
{ ngx_string("HTTP_IF_RANGE"), ngx_string("") },
|
397
|
+
{ ngx_null_string, ngx_null_string }
|
398
|
+
};
|
399
|
+
|
400
|
+
#endif
|
401
|
+
|
402
|
+
|
403
|
+
static ngx_path_init_t ngx_http_uwsgi_temp_path = {
|
404
|
+
ngx_string(NGX_HTTP_UWSGI_TEMP_PATH), { 1, 2, 0 }
|
405
|
+
};
|
406
|
+
|
407
|
+
|
408
|
+
static ngx_int_t
|
409
|
+
ngx_http_uwsgi_handler(ngx_http_request_t *r)
|
410
|
+
{
|
411
|
+
ngx_int_t rc;
|
412
|
+
ngx_http_status_t *status;
|
413
|
+
ngx_http_upstream_t *u;
|
414
|
+
ngx_http_uwsgi_loc_conf_t *uwcf;
|
415
|
+
|
416
|
+
if (r->subrequest_in_memory) {
|
417
|
+
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
418
|
+
"ngx_http_uwsgi_module does not support "
|
419
|
+
"subrequests in memory");
|
420
|
+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
421
|
+
}
|
422
|
+
|
423
|
+
if (ngx_http_upstream_create(r) != NGX_OK) {
|
424
|
+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
425
|
+
}
|
426
|
+
|
427
|
+
status = ngx_pcalloc(r->pool, sizeof(ngx_http_status_t));
|
428
|
+
if (status == NULL) {
|
429
|
+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
430
|
+
}
|
431
|
+
|
432
|
+
ngx_http_set_ctx(r, status, ngx_http_uwsgi_module);
|
433
|
+
|
434
|
+
uwcf = ngx_http_get_module_loc_conf(r, ngx_http_uwsgi_module);
|
435
|
+
|
436
|
+
if (uwcf->uwsgi_lengths) {
|
437
|
+
if (ngx_http_uwsgi_eval(r, uwcf) != NGX_OK) {
|
438
|
+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
439
|
+
}
|
440
|
+
}
|
441
|
+
|
442
|
+
u = r->upstream;
|
443
|
+
|
444
|
+
ngx_str_set(&u->schema, "uwsgi://");
|
445
|
+
u->output.tag = (ngx_buf_tag_t) &ngx_http_uwsgi_module;
|
446
|
+
|
447
|
+
u->conf = &uwcf->upstream;
|
448
|
+
|
449
|
+
#if (NGX_HTTP_CACHE)
|
450
|
+
u->create_key = ngx_http_uwsgi_create_key;
|
451
|
+
#endif
|
452
|
+
u->create_request = ngx_http_uwsgi_create_request;
|
453
|
+
u->reinit_request = ngx_http_uwsgi_reinit_request;
|
454
|
+
u->process_header = ngx_http_uwsgi_process_status_line;
|
455
|
+
u->abort_request = ngx_http_uwsgi_abort_request;
|
456
|
+
u->finalize_request = ngx_http_uwsgi_finalize_request;
|
457
|
+
|
458
|
+
u->buffering = uwcf->upstream.buffering;
|
459
|
+
|
460
|
+
u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
|
461
|
+
if (u->pipe == NULL) {
|
462
|
+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
463
|
+
}
|
464
|
+
|
465
|
+
u->pipe->input_filter = ngx_event_pipe_copy_input_filter;
|
466
|
+
u->pipe->input_ctx = r;
|
467
|
+
|
468
|
+
rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init);
|
469
|
+
|
470
|
+
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
471
|
+
return rc;
|
472
|
+
}
|
473
|
+
|
474
|
+
return NGX_DONE;
|
475
|
+
}
|
476
|
+
|
477
|
+
|
478
|
+
static ngx_int_t
|
479
|
+
ngx_http_uwsgi_eval(ngx_http_request_t *r, ngx_http_uwsgi_loc_conf_t * uwcf)
|
480
|
+
{
|
481
|
+
ngx_url_t url;
|
482
|
+
ngx_http_upstream_t *u;
|
483
|
+
|
484
|
+
ngx_memzero(&url, sizeof(ngx_url_t));
|
485
|
+
|
486
|
+
if (ngx_http_script_run(r, &url.url, uwcf->uwsgi_lengths->elts, 0,
|
487
|
+
uwcf->uwsgi_values->elts)
|
488
|
+
== NULL)
|
489
|
+
{
|
490
|
+
return NGX_ERROR;
|
491
|
+
}
|
492
|
+
|
493
|
+
url.no_resolve = 1;
|
494
|
+
|
495
|
+
if (ngx_parse_url(r->pool, &url) != NGX_OK) {
|
496
|
+
if (url.err) {
|
497
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
498
|
+
"%s in upstream \"%V\"", url.err, &url.url);
|
499
|
+
}
|
500
|
+
|
501
|
+
return NGX_ERROR;
|
502
|
+
}
|
503
|
+
|
504
|
+
u = r->upstream;
|
505
|
+
|
506
|
+
u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
|
507
|
+
if (u->resolved == NULL) {
|
508
|
+
return NGX_ERROR;
|
509
|
+
}
|
510
|
+
|
511
|
+
if (url.addrs && url.addrs[0].sockaddr) {
|
512
|
+
u->resolved->sockaddr = url.addrs[0].sockaddr;
|
513
|
+
u->resolved->socklen = url.addrs[0].socklen;
|
514
|
+
u->resolved->naddrs = 1;
|
515
|
+
u->resolved->host = url.addrs[0].name;
|
516
|
+
|
517
|
+
} else {
|
518
|
+
u->resolved->host = url.host;
|
519
|
+
u->resolved->port = url.port;
|
520
|
+
u->resolved->no_port = url.no_port;
|
521
|
+
}
|
522
|
+
|
523
|
+
return NGX_OK;
|
524
|
+
}
|
525
|
+
|
526
|
+
|
527
|
+
#if (NGX_HTTP_CACHE)
|
528
|
+
|
529
|
+
static ngx_int_t
|
530
|
+
ngx_http_uwsgi_create_key(ngx_http_request_t *r)
|
531
|
+
{
|
532
|
+
ngx_str_t *key;
|
533
|
+
ngx_http_uwsgi_loc_conf_t *uwcf;
|
534
|
+
|
535
|
+
key = ngx_array_push(&r->cache->keys);
|
536
|
+
if (key == NULL) {
|
537
|
+
return NGX_ERROR;
|
538
|
+
}
|
539
|
+
|
540
|
+
uwcf = ngx_http_get_module_loc_conf(r, ngx_http_uwsgi_module);
|
541
|
+
|
542
|
+
if (ngx_http_complex_value(r, &uwcf->cache_key, key) != NGX_OK) {
|
543
|
+
return NGX_ERROR;
|
544
|
+
}
|
545
|
+
|
546
|
+
return NGX_OK;
|
547
|
+
}
|
548
|
+
|
549
|
+
#endif
|
550
|
+
|
551
|
+
|
552
|
+
static ngx_int_t
|
553
|
+
ngx_http_uwsgi_create_request(ngx_http_request_t *r)
|
554
|
+
{
|
555
|
+
u_char ch, *lowcase_key;
|
556
|
+
size_t key_len, val_len, len, allocated;
|
557
|
+
ngx_uint_t i, n, hash, header_params;
|
558
|
+
ngx_buf_t *b;
|
559
|
+
ngx_chain_t *cl, *body;
|
560
|
+
ngx_list_part_t *part;
|
561
|
+
ngx_table_elt_t *header, **ignored;
|
562
|
+
ngx_http_script_code_pt code;
|
563
|
+
ngx_http_script_engine_t e, le;
|
564
|
+
ngx_http_uwsgi_loc_conf_t *uwcf;
|
565
|
+
ngx_http_script_len_code_pt lcode;
|
566
|
+
|
567
|
+
len = 0;
|
568
|
+
header_params = 0;
|
569
|
+
ignored = NULL;
|
570
|
+
|
571
|
+
uwcf = ngx_http_get_module_loc_conf(r, ngx_http_uwsgi_module);
|
572
|
+
|
573
|
+
if (uwcf->params_len) {
|
574
|
+
ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
|
575
|
+
|
576
|
+
ngx_http_script_flush_no_cacheable_variables(r, uwcf->flushes);
|
577
|
+
le.flushed = 1;
|
578
|
+
|
579
|
+
le.ip = uwcf->params_len->elts;
|
580
|
+
le.request = r;
|
581
|
+
|
582
|
+
while (*(uintptr_t *) le.ip) {
|
583
|
+
|
584
|
+
lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
585
|
+
key_len = lcode(&le);
|
586
|
+
|
587
|
+
for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode (&le)) {
|
588
|
+
lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
589
|
+
}
|
590
|
+
le.ip += sizeof(uintptr_t);
|
591
|
+
|
592
|
+
len += 2 + key_len + 2 + val_len;
|
593
|
+
}
|
594
|
+
}
|
595
|
+
|
596
|
+
if (uwcf->upstream.pass_request_headers) {
|
597
|
+
|
598
|
+
allocated = 0;
|
599
|
+
lowcase_key = NULL;
|
600
|
+
|
601
|
+
if (uwcf->header_params) {
|
602
|
+
n = 0;
|
603
|
+
part = &r->headers_in.headers.part;
|
604
|
+
|
605
|
+
while (part) {
|
606
|
+
n += part->nelts;
|
607
|
+
part = part->next;
|
608
|
+
}
|
609
|
+
|
610
|
+
ignored = ngx_palloc(r->pool, n * sizeof(void *));
|
611
|
+
if (ignored == NULL) {
|
612
|
+
return NGX_ERROR;
|
613
|
+
}
|
614
|
+
}
|
615
|
+
|
616
|
+
part = &r->headers_in.headers.part;
|
617
|
+
header = part->elts;
|
618
|
+
|
619
|
+
for (i = 0; /* void */ ; i++) {
|
620
|
+
|
621
|
+
if (i >= part->nelts) {
|
622
|
+
if (part->next == NULL) {
|
623
|
+
break;
|
624
|
+
}
|
625
|
+
|
626
|
+
part = part->next;
|
627
|
+
header = part->elts;
|
628
|
+
i = 0;
|
629
|
+
}
|
630
|
+
|
631
|
+
if (uwcf->header_params) {
|
632
|
+
if (allocated < header[i].key.len) {
|
633
|
+
allocated = header[i].key.len + 16;
|
634
|
+
lowcase_key = ngx_pnalloc(r->pool, allocated);
|
635
|
+
if (lowcase_key == NULL) {
|
636
|
+
return NGX_ERROR;
|
637
|
+
}
|
638
|
+
}
|
639
|
+
|
640
|
+
hash = 0;
|
641
|
+
|
642
|
+
for (n = 0; n < header[i].key.len; n++) {
|
643
|
+
ch = header[i].key.data[n];
|
644
|
+
|
645
|
+
if (ch >= 'A' && ch <= 'Z') {
|
646
|
+
ch |= 0x20;
|
647
|
+
|
648
|
+
} else if (ch == '-') {
|
649
|
+
ch = '_';
|
650
|
+
}
|
651
|
+
|
652
|
+
hash = ngx_hash(hash, ch);
|
653
|
+
lowcase_key[n] = ch;
|
654
|
+
}
|
655
|
+
|
656
|
+
if (ngx_hash_find(&uwcf->headers_hash, hash, lowcase_key, n)) {
|
657
|
+
ignored[header_params++] = &header[i];
|
658
|
+
continue;
|
659
|
+
}
|
660
|
+
}
|
661
|
+
|
662
|
+
len += 2 + sizeof("HTTP_") - 1 + header[i].key.len
|
663
|
+
+ 2 + header[i].value.len;
|
664
|
+
}
|
665
|
+
}
|
666
|
+
|
667
|
+
len += uwcf->uwsgi_string.len;
|
668
|
+
|
669
|
+
#if 0
|
670
|
+
/* allow custom uwsgi packet */
|
671
|
+
if (len > 0 && len < 2) {
|
672
|
+
ngx_log_error (NGX_LOG_ALERT, r->connection->log, 0,
|
673
|
+
"uwsgi request is too little: %uz", len);
|
674
|
+
return NGX_ERROR;
|
675
|
+
}
|
676
|
+
#endif
|
677
|
+
|
678
|
+
b = ngx_create_temp_buf(r->pool, len + 4);
|
679
|
+
if (b == NULL) {
|
680
|
+
return NGX_ERROR;
|
681
|
+
}
|
682
|
+
|
683
|
+
cl = ngx_alloc_chain_link(r->pool);
|
684
|
+
if (cl == NULL) {
|
685
|
+
return NGX_ERROR;
|
686
|
+
}
|
687
|
+
|
688
|
+
cl->buf = b;
|
689
|
+
|
690
|
+
*b->last++ = (u_char) uwcf->modifier1;
|
691
|
+
*b->last++ = (u_char) (len & 0xff);
|
692
|
+
*b->last++ = (u_char) ((len >> 8) & 0xff);
|
693
|
+
*b->last++ = (u_char) uwcf->modifier2;
|
694
|
+
|
695
|
+
if (uwcf->params_len) {
|
696
|
+
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
|
697
|
+
|
698
|
+
e.ip = uwcf->params->elts;
|
699
|
+
e.pos = b->last;
|
700
|
+
e.request = r;
|
701
|
+
e.flushed = 1;
|
702
|
+
|
703
|
+
le.ip = uwcf->params_len->elts;
|
704
|
+
|
705
|
+
while (*(uintptr_t *) le.ip) {
|
706
|
+
|
707
|
+
lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
708
|
+
key_len = (u_char) lcode (&le);
|
709
|
+
|
710
|
+
for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
|
711
|
+
lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
712
|
+
}
|
713
|
+
le.ip += sizeof(uintptr_t);
|
714
|
+
|
715
|
+
*e.pos++ = (u_char) (key_len & 0xff);
|
716
|
+
*e.pos++ = (u_char) ((key_len >> 8) & 0xff);
|
717
|
+
|
718
|
+
code = *(ngx_http_script_code_pt *) e.ip;
|
719
|
+
code((ngx_http_script_engine_t *) & e);
|
720
|
+
|
721
|
+
*e.pos++ = (u_char) (val_len & 0xff);
|
722
|
+
*e.pos++ = (u_char) ((val_len >> 8) & 0xff);
|
723
|
+
|
724
|
+
while (*(uintptr_t *) e.ip) {
|
725
|
+
code = *(ngx_http_script_code_pt *) e.ip;
|
726
|
+
code((ngx_http_script_engine_t *) & e);
|
727
|
+
}
|
728
|
+
|
729
|
+
e.ip += sizeof(uintptr_t);
|
730
|
+
|
731
|
+
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
732
|
+
"uwsgi param: \"%*s: %*s\"",
|
733
|
+
key_len, e.pos - (key_len + 2 + val_len),
|
734
|
+
val_len, e.pos - val_len);
|
735
|
+
}
|
736
|
+
|
737
|
+
b->last = e.pos;
|
738
|
+
}
|
739
|
+
|
740
|
+
if (uwcf->upstream.pass_request_headers) {
|
741
|
+
|
742
|
+
part = &r->headers_in.headers.part;
|
743
|
+
header = part->elts;
|
744
|
+
|
745
|
+
for (i = 0; /* void */ ; i++) {
|
746
|
+
|
747
|
+
if (i >= part->nelts) {
|
748
|
+
if (part->next == NULL) {
|
749
|
+
break;
|
750
|
+
}
|
751
|
+
|
752
|
+
part = part->next;
|
753
|
+
header = part->elts;
|
754
|
+
i = 0;
|
755
|
+
}
|
756
|
+
|
757
|
+
for (n = 0; n < header_params; n++) {
|
758
|
+
if (&header[i] == ignored[n]) {
|
759
|
+
goto next;
|
760
|
+
}
|
761
|
+
}
|
762
|
+
|
763
|
+
key_len = sizeof("HTTP_") - 1 + header[i].key.len;
|
764
|
+
*b->last++ = (u_char) (key_len & 0xff);
|
765
|
+
*b->last++ = (u_char) ((key_len >> 8) & 0xff);
|
766
|
+
|
767
|
+
b->last = ngx_cpymem(b->last, "HTTP_", sizeof("HTTP_") - 1);
|
768
|
+
for (n = 0; n < header[i].key.len; n++) {
|
769
|
+
ch = header[i].key.data[n];
|
770
|
+
|
771
|
+
if (ch >= 'a' && ch <= 'z') {
|
772
|
+
ch &= ~0x20;
|
773
|
+
|
774
|
+
} else if (ch == '-') {
|
775
|
+
ch = '_';
|
776
|
+
}
|
777
|
+
|
778
|
+
*b->last++ = ch;
|
779
|
+
}
|
780
|
+
|
781
|
+
val_len = header[i].value.len;
|
782
|
+
*b->last++ = (u_char) (val_len & 0xff);
|
783
|
+
*b->last++ = (u_char) ((val_len >> 8) & 0xff);
|
784
|
+
b->last = ngx_copy(b->last, header[i].value.data, val_len);
|
785
|
+
|
786
|
+
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
787
|
+
"uwsgi param: \"%*s: %*s\"",
|
788
|
+
key_len, b->last - (key_len + 2 + val_len),
|
789
|
+
val_len, b->last - val_len);
|
790
|
+
next:
|
791
|
+
|
792
|
+
continue;
|
793
|
+
}
|
794
|
+
}
|
795
|
+
|
796
|
+
b->last = ngx_copy(b->last, uwcf->uwsgi_string.data,
|
797
|
+
uwcf->uwsgi_string.len);
|
798
|
+
|
799
|
+
if (uwcf->upstream.pass_request_body) {
|
800
|
+
body = r->upstream->request_bufs;
|
801
|
+
r->upstream->request_bufs = cl;
|
802
|
+
|
803
|
+
while (body) {
|
804
|
+
b = ngx_alloc_buf(r->pool);
|
805
|
+
if (b == NULL) {
|
806
|
+
return NGX_ERROR;
|
807
|
+
}
|
808
|
+
|
809
|
+
ngx_memcpy(b, body->buf, sizeof(ngx_buf_t));
|
810
|
+
|
811
|
+
cl->next = ngx_alloc_chain_link(r->pool);
|
812
|
+
if (cl->next == NULL) {
|
813
|
+
return NGX_ERROR;
|
814
|
+
}
|
815
|
+
|
816
|
+
cl = cl->next;
|
817
|
+
cl->buf = b;
|
818
|
+
|
819
|
+
body = body->next;
|
820
|
+
}
|
821
|
+
|
822
|
+
} else {
|
823
|
+
r->upstream->request_bufs = cl;
|
824
|
+
}
|
825
|
+
|
826
|
+
cl->next = NULL;
|
827
|
+
|
828
|
+
return NGX_OK;
|
829
|
+
}
|
830
|
+
|
831
|
+
|
832
|
+
static ngx_int_t
|
833
|
+
ngx_http_uwsgi_reinit_request(ngx_http_request_t *r)
|
834
|
+
{
|
835
|
+
ngx_http_status_t *status;
|
836
|
+
|
837
|
+
status = ngx_http_get_module_ctx(r, ngx_http_uwsgi_module);
|
838
|
+
|
839
|
+
if (status == NULL) {
|
840
|
+
return NGX_OK;
|
841
|
+
}
|
842
|
+
|
843
|
+
status->code = 0;
|
844
|
+
status->count = 0;
|
845
|
+
status->start = NULL;
|
846
|
+
status->end = NULL;
|
847
|
+
|
848
|
+
r->upstream->process_header = ngx_http_uwsgi_process_status_line;
|
849
|
+
|
850
|
+
return NGX_OK;
|
851
|
+
}
|
852
|
+
|
853
|
+
|
854
|
+
static ngx_int_t
|
855
|
+
ngx_http_uwsgi_process_status_line(ngx_http_request_t *r)
|
856
|
+
{
|
857
|
+
size_t len;
|
858
|
+
ngx_int_t rc;
|
859
|
+
ngx_http_status_t *status;
|
860
|
+
ngx_http_upstream_t *u;
|
861
|
+
|
862
|
+
status = ngx_http_get_module_ctx(r, ngx_http_uwsgi_module);
|
863
|
+
|
864
|
+
if (status == NULL) {
|
865
|
+
return NGX_ERROR;
|
866
|
+
}
|
867
|
+
|
868
|
+
u = r->upstream;
|
869
|
+
|
870
|
+
rc = ngx_http_parse_status_line(r, &u->buffer, status);
|
871
|
+
|
872
|
+
if (rc == NGX_AGAIN) {
|
873
|
+
return rc;
|
874
|
+
}
|
875
|
+
|
876
|
+
if (rc == NGX_ERROR) {
|
877
|
+
r->http_version = NGX_HTTP_VERSION_9;
|
878
|
+
|
879
|
+
u->process_header = ngx_http_uwsgi_process_header;
|
880
|
+
|
881
|
+
return ngx_http_uwsgi_process_header(r);
|
882
|
+
}
|
883
|
+
|
884
|
+
if (u->state) {
|
885
|
+
u->state->status = status->code;
|
886
|
+
}
|
887
|
+
|
888
|
+
u->headers_in.status_n = status->code;
|
889
|
+
|
890
|
+
len = status->end - status->start;
|
891
|
+
u->headers_in.status_line.len = len;
|
892
|
+
|
893
|
+
u->headers_in.status_line.data = ngx_pnalloc(r->pool, len);
|
894
|
+
if (u->headers_in.status_line.data == NULL) {
|
895
|
+
return NGX_ERROR;
|
896
|
+
}
|
897
|
+
|
898
|
+
ngx_memcpy(u->headers_in.status_line.data, status->start, len);
|
899
|
+
|
900
|
+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
901
|
+
"http uwsgi status %ui \"%V\"",
|
902
|
+
u->headers_in.status_n, &u->headers_in.status_line);
|
903
|
+
|
904
|
+
u->process_header = ngx_http_uwsgi_process_header;
|
905
|
+
|
906
|
+
return ngx_http_uwsgi_process_header(r);
|
907
|
+
}
|
908
|
+
|
909
|
+
|
910
|
+
static ngx_int_t
|
911
|
+
ngx_http_uwsgi_process_header(ngx_http_request_t *r)
|
912
|
+
{
|
913
|
+
ngx_str_t *status_line;
|
914
|
+
ngx_int_t rc, status;
|
915
|
+
ngx_table_elt_t *h;
|
916
|
+
ngx_http_upstream_t *u;
|
917
|
+
ngx_http_upstream_header_t *hh;
|
918
|
+
ngx_http_upstream_main_conf_t *umcf;
|
919
|
+
|
920
|
+
umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
921
|
+
|
922
|
+
for ( ;; ) {
|
923
|
+
|
924
|
+
rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1);
|
925
|
+
|
926
|
+
if (rc == NGX_OK) {
|
927
|
+
|
928
|
+
/* a header line has been parsed successfully */
|
929
|
+
|
930
|
+
h = ngx_list_push(&r->upstream->headers_in.headers);
|
931
|
+
if (h == NULL) {
|
932
|
+
return NGX_ERROR;
|
933
|
+
}
|
934
|
+
|
935
|
+
h->hash = r->header_hash;
|
936
|
+
|
937
|
+
h->key.len = r->header_name_end - r->header_name_start;
|
938
|
+
h->value.len = r->header_end - r->header_start;
|
939
|
+
|
940
|
+
h->key.data = ngx_pnalloc(r->pool,
|
941
|
+
h->key.len + 1 + h->value.len + 1
|
942
|
+
+ h->key.len);
|
943
|
+
if (h->key.data == NULL) {
|
944
|
+
return NGX_ERROR;
|
945
|
+
}
|
946
|
+
|
947
|
+
h->value.data = h->key.data + h->key.len + 1;
|
948
|
+
h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1;
|
949
|
+
|
950
|
+
ngx_memcpy(h->key.data, r->header_name_start, h->key.len);
|
951
|
+
h->key.data[h->key.len] = '\0';
|
952
|
+
ngx_memcpy(h->value.data, r->header_start, h->value.len);
|
953
|
+
h->value.data[h->value.len] = '\0';
|
954
|
+
|
955
|
+
if (h->key.len == r->lowcase_index) {
|
956
|
+
ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len);
|
957
|
+
|
958
|
+
} else {
|
959
|
+
ngx_strlow(h->lowcase_key, h->key.data, h->key.len);
|
960
|
+
}
|
961
|
+
|
962
|
+
hh = ngx_hash_find(&umcf->headers_in_hash, h->hash,
|
963
|
+
h->lowcase_key, h->key.len);
|
964
|
+
|
965
|
+
if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
|
966
|
+
return NGX_ERROR;
|
967
|
+
}
|
968
|
+
|
969
|
+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
970
|
+
"http uwsgi header: \"%V: %V\"", &h->key, &h->value);
|
971
|
+
|
972
|
+
continue;
|
973
|
+
}
|
974
|
+
|
975
|
+
if (rc == NGX_HTTP_PARSE_HEADER_DONE) {
|
976
|
+
|
977
|
+
/* a whole header has been parsed successfully */
|
978
|
+
|
979
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
980
|
+
"http uwsgi header done");
|
981
|
+
|
982
|
+
if (r->http_version > NGX_HTTP_VERSION_9) {
|
983
|
+
return NGX_OK;
|
984
|
+
}
|
985
|
+
|
986
|
+
u = r->upstream;
|
987
|
+
|
988
|
+
if (u->headers_in.status) {
|
989
|
+
status_line = &u->headers_in.status->value;
|
990
|
+
|
991
|
+
status = ngx_atoi(status_line->data, 3);
|
992
|
+
if (status == NGX_ERROR) {
|
993
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
994
|
+
"upstream sent invalid status \"%V\"",
|
995
|
+
status_line);
|
996
|
+
return NGX_HTTP_UPSTREAM_INVALID_HEADER;
|
997
|
+
}
|
998
|
+
|
999
|
+
r->http_version = NGX_HTTP_VERSION_10;
|
1000
|
+
u->headers_in.status_n = status;
|
1001
|
+
u->headers_in.status_line = *status_line;
|
1002
|
+
|
1003
|
+
} else if (u->headers_in.location) {
|
1004
|
+
r->http_version = NGX_HTTP_VERSION_10;
|
1005
|
+
u->headers_in.status_n = 302;
|
1006
|
+
ngx_str_set(&u->headers_in.status_line,
|
1007
|
+
"302 Moved Temporarily");
|
1008
|
+
|
1009
|
+
} else {
|
1010
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
1011
|
+
"upstream sent neither valid HTTP/1.0 header "
|
1012
|
+
"nor \"Status\" header line");
|
1013
|
+
u->headers_in.status_n = 200;
|
1014
|
+
ngx_str_set(&u->headers_in.status_line, "200 OK");
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
if (u->state) {
|
1018
|
+
u->state->status = u->headers_in.status_n;
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
return NGX_OK;
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
if (rc == NGX_AGAIN) {
|
1025
|
+
return NGX_AGAIN;
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
/* there was error while a header line parsing */
|
1029
|
+
|
1030
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
1031
|
+
"upstream sent invalid header");
|
1032
|
+
|
1033
|
+
return NGX_HTTP_UPSTREAM_INVALID_HEADER;
|
1034
|
+
}
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
|
1038
|
+
static void
|
1039
|
+
ngx_http_uwsgi_abort_request(ngx_http_request_t *r)
|
1040
|
+
{
|
1041
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1042
|
+
"abort http uwsgi request");
|
1043
|
+
|
1044
|
+
return;
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
|
1048
|
+
static void
|
1049
|
+
ngx_http_uwsgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
|
1050
|
+
{
|
1051
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1052
|
+
"finalize http uwsgi request");
|
1053
|
+
|
1054
|
+
return;
|
1055
|
+
}
|
1056
|
+
|
1057
|
+
|
1058
|
+
static void *
|
1059
|
+
ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf)
|
1060
|
+
{
|
1061
|
+
ngx_http_uwsgi_loc_conf_t *conf;
|
1062
|
+
|
1063
|
+
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_uwsgi_loc_conf_t));
|
1064
|
+
if (conf == NULL) {
|
1065
|
+
return NULL;
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
conf->modifier1 = NGX_CONF_UNSET_UINT;
|
1069
|
+
conf->modifier2 = NGX_CONF_UNSET_UINT;
|
1070
|
+
|
1071
|
+
conf->upstream.store = NGX_CONF_UNSET;
|
1072
|
+
conf->upstream.store_access = NGX_CONF_UNSET_UINT;
|
1073
|
+
conf->upstream.buffering = NGX_CONF_UNSET;
|
1074
|
+
conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
|
1075
|
+
|
1076
|
+
conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
|
1077
|
+
conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC;
|
1078
|
+
conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC;
|
1079
|
+
|
1080
|
+
conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE;
|
1081
|
+
conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE;
|
1082
|
+
|
1083
|
+
conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
|
1084
|
+
conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
|
1085
|
+
conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
|
1086
|
+
|
1087
|
+
conf->upstream.pass_request_headers = NGX_CONF_UNSET;
|
1088
|
+
conf->upstream.pass_request_body = NGX_CONF_UNSET;
|
1089
|
+
|
1090
|
+
#if (NGX_HTTP_CACHE)
|
1091
|
+
conf->upstream.cache = NGX_CONF_UNSET_PTR;
|
1092
|
+
conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT;
|
1093
|
+
conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR;
|
1094
|
+
conf->upstream.no_cache = NGX_CONF_UNSET_PTR;
|
1095
|
+
conf->upstream.cache_valid = NGX_CONF_UNSET_PTR;
|
1096
|
+
#endif
|
1097
|
+
|
1098
|
+
conf->upstream.hide_headers = NGX_CONF_UNSET_PTR;
|
1099
|
+
conf->upstream.pass_headers = NGX_CONF_UNSET_PTR;
|
1100
|
+
|
1101
|
+
conf->upstream.intercept_errors = NGX_CONF_UNSET;
|
1102
|
+
|
1103
|
+
/* "uwsgi_cyclic_temp_file" is disabled */
|
1104
|
+
conf->upstream.cyclic_temp_file = 0;
|
1105
|
+
|
1106
|
+
conf->upstream.change_buffering = 1;
|
1107
|
+
|
1108
|
+
ngx_str_set(&conf->upstream.module, "uwsgi");
|
1109
|
+
|
1110
|
+
return conf;
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
|
1114
|
+
static char *
|
1115
|
+
ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
1116
|
+
{
|
1117
|
+
ngx_http_uwsgi_loc_conf_t *prev = parent;
|
1118
|
+
ngx_http_uwsgi_loc_conf_t *conf = child;
|
1119
|
+
|
1120
|
+
size_t size;
|
1121
|
+
ngx_hash_init_t hash;
|
1122
|
+
ngx_http_core_loc_conf_t *clcf;
|
1123
|
+
|
1124
|
+
if (conf->upstream.store != 0) {
|
1125
|
+
ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
|
1126
|
+
|
1127
|
+
if (conf->upstream.store_lengths == NULL) {
|
1128
|
+
conf->upstream.store_lengths = prev->upstream.store_lengths;
|
1129
|
+
conf->upstream.store_values = prev->upstream.store_values;
|
1130
|
+
}
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
ngx_conf_merge_uint_value(conf->upstream.store_access,
|
1134
|
+
prev->upstream.store_access, 0600);
|
1135
|
+
|
1136
|
+
ngx_conf_merge_value(conf->upstream.buffering,
|
1137
|
+
prev->upstream.buffering, 1);
|
1138
|
+
|
1139
|
+
ngx_conf_merge_value(conf->upstream.ignore_client_abort,
|
1140
|
+
prev->upstream.ignore_client_abort, 0);
|
1141
|
+
|
1142
|
+
ngx_conf_merge_msec_value(conf->upstream.connect_timeout,
|
1143
|
+
prev->upstream.connect_timeout, 60000);
|
1144
|
+
|
1145
|
+
ngx_conf_merge_msec_value(conf->upstream.send_timeout,
|
1146
|
+
prev->upstream.send_timeout, 60000);
|
1147
|
+
|
1148
|
+
ngx_conf_merge_msec_value(conf->upstream.read_timeout,
|
1149
|
+
prev->upstream.read_timeout, 60000);
|
1150
|
+
|
1151
|
+
ngx_conf_merge_size_value(conf->upstream.send_lowat,
|
1152
|
+
prev->upstream.send_lowat, 0);
|
1153
|
+
|
1154
|
+
ngx_conf_merge_size_value(conf->upstream.buffer_size,
|
1155
|
+
prev->upstream.buffer_size,
|
1156
|
+
(size_t) ngx_pagesize);
|
1157
|
+
|
1158
|
+
|
1159
|
+
ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,
|
1160
|
+
8, ngx_pagesize);
|
1161
|
+
|
1162
|
+
if (conf->upstream.bufs.num < 2) {
|
1163
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1164
|
+
"there must be at least 2 \"uwsgi_buffers\"");
|
1165
|
+
return NGX_CONF_ERROR;
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
|
1169
|
+
size = conf->upstream.buffer_size;
|
1170
|
+
if (size < conf->upstream.bufs.size) {
|
1171
|
+
size = conf->upstream.bufs.size;
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
|
1175
|
+
ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf,
|
1176
|
+
prev->upstream.busy_buffers_size_conf,
|
1177
|
+
NGX_CONF_UNSET_SIZE);
|
1178
|
+
|
1179
|
+
if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) {
|
1180
|
+
conf->upstream.busy_buffers_size = 2 * size;
|
1181
|
+
} else {
|
1182
|
+
conf->upstream.busy_buffers_size =
|
1183
|
+
conf->upstream.busy_buffers_size_conf;
|
1184
|
+
}
|
1185
|
+
|
1186
|
+
if (conf->upstream.busy_buffers_size < size) {
|
1187
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1188
|
+
"\"uwsgi_busy_buffers_size\" must be equal or bigger "
|
1189
|
+
"than maximum of the value of \"uwsgi_buffer_size\" and "
|
1190
|
+
"one of the \"uwsgi_buffers\"");
|
1191
|
+
|
1192
|
+
return NGX_CONF_ERROR;
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
if (conf->upstream.busy_buffers_size
|
1196
|
+
> (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size)
|
1197
|
+
{
|
1198
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1199
|
+
"\"uwsgi_busy_buffers_size\" must be less than "
|
1200
|
+
"the size of all \"uwsgi_buffers\" minus one buffer");
|
1201
|
+
|
1202
|
+
return NGX_CONF_ERROR;
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
|
1206
|
+
ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf,
|
1207
|
+
prev->upstream.temp_file_write_size_conf,
|
1208
|
+
NGX_CONF_UNSET_SIZE);
|
1209
|
+
|
1210
|
+
if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) {
|
1211
|
+
conf->upstream.temp_file_write_size = 2 * size;
|
1212
|
+
} else {
|
1213
|
+
conf->upstream.temp_file_write_size =
|
1214
|
+
conf->upstream.temp_file_write_size_conf;
|
1215
|
+
}
|
1216
|
+
|
1217
|
+
if (conf->upstream.temp_file_write_size < size) {
|
1218
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1219
|
+
"\"uwsgi_temp_file_write_size\" must be equal or bigger than "
|
1220
|
+
"maximum of the value of \"uwsgi_buffer_size\" and "
|
1221
|
+
"one of the \"uwsgi_buffers\"");
|
1222
|
+
|
1223
|
+
return NGX_CONF_ERROR;
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
|
1227
|
+
ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf,
|
1228
|
+
prev->upstream.max_temp_file_size_conf,
|
1229
|
+
NGX_CONF_UNSET_SIZE);
|
1230
|
+
|
1231
|
+
if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) {
|
1232
|
+
conf->upstream.max_temp_file_size = 1024 * 1024 * 1024;
|
1233
|
+
} else {
|
1234
|
+
conf->upstream.max_temp_file_size =
|
1235
|
+
conf->upstream.max_temp_file_size_conf;
|
1236
|
+
}
|
1237
|
+
|
1238
|
+
if (conf->upstream.max_temp_file_size != 0
|
1239
|
+
&& conf->upstream.max_temp_file_size < size) {
|
1240
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1241
|
+
"\"uwsgi_max_temp_file_size\" must be equal to zero to disable "
|
1242
|
+
"the temporary files usage or must be equal or bigger than "
|
1243
|
+
"maximum of the value of \"uwsgi_buffer_size\" and "
|
1244
|
+
"one of the \"uwsgi_buffers\"");
|
1245
|
+
|
1246
|
+
return NGX_CONF_ERROR;
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
|
1250
|
+
ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers,
|
1251
|
+
prev->upstream.ignore_headers,
|
1252
|
+
NGX_CONF_BITMASK_SET);
|
1253
|
+
|
1254
|
+
|
1255
|
+
ngx_conf_merge_bitmask_value(conf->upstream.next_upstream,
|
1256
|
+
prev->upstream.next_upstream,
|
1257
|
+
(NGX_CONF_BITMASK_SET
|
1258
|
+
|NGX_HTTP_UPSTREAM_FT_ERROR
|
1259
|
+
|NGX_HTTP_UPSTREAM_FT_TIMEOUT));
|
1260
|
+
|
1261
|
+
if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
|
1262
|
+
conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
|
1263
|
+
|NGX_HTTP_UPSTREAM_FT_OFF;
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path,
|
1267
|
+
prev->upstream.temp_path,
|
1268
|
+
&ngx_http_uwsgi_temp_path)
|
1269
|
+
!= NGX_OK)
|
1270
|
+
{
|
1271
|
+
return NGX_CONF_ERROR;
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
#if (NGX_HTTP_CACHE)
|
1275
|
+
|
1276
|
+
ngx_conf_merge_ptr_value(conf->upstream.cache,
|
1277
|
+
prev->upstream.cache, NULL);
|
1278
|
+
|
1279
|
+
if (conf->upstream.cache && conf->upstream.cache->data == NULL) {
|
1280
|
+
ngx_shm_zone_t *shm_zone;
|
1281
|
+
|
1282
|
+
shm_zone = conf->upstream.cache;
|
1283
|
+
|
1284
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1285
|
+
"\"uwsgi_cache\" zone \"%V\" is unknown",
|
1286
|
+
&shm_zone->shm.name);
|
1287
|
+
|
1288
|
+
return NGX_CONF_ERROR;
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
ngx_conf_merge_uint_value(conf->upstream.cache_min_uses,
|
1292
|
+
prev->upstream.cache_min_uses, 1);
|
1293
|
+
|
1294
|
+
ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale,
|
1295
|
+
prev->upstream.cache_use_stale,
|
1296
|
+
(NGX_CONF_BITMASK_SET
|
1297
|
+
|NGX_HTTP_UPSTREAM_FT_OFF));
|
1298
|
+
|
1299
|
+
if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) {
|
1300
|
+
conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET
|
1301
|
+
|NGX_HTTP_UPSTREAM_FT_OFF;
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_ERROR) {
|
1305
|
+
conf->upstream.cache_use_stale |= NGX_HTTP_UPSTREAM_FT_NOLIVE;
|
1306
|
+
}
|
1307
|
+
|
1308
|
+
if (conf->upstream.cache_methods == 0) {
|
1309
|
+
conf->upstream.cache_methods = prev->upstream.cache_methods;
|
1310
|
+
}
|
1311
|
+
|
1312
|
+
conf->upstream.cache_methods |= NGX_HTTP_GET|NGX_HTTP_HEAD;
|
1313
|
+
|
1314
|
+
ngx_conf_merge_ptr_value(conf->upstream.cache_bypass,
|
1315
|
+
prev->upstream.cache_bypass, NULL);
|
1316
|
+
|
1317
|
+
ngx_conf_merge_ptr_value(conf->upstream.no_cache,
|
1318
|
+
prev->upstream.no_cache, NULL);
|
1319
|
+
|
1320
|
+
ngx_conf_merge_ptr_value(conf->upstream.cache_valid,
|
1321
|
+
prev->upstream.cache_valid, NULL);
|
1322
|
+
|
1323
|
+
if (conf->cache_key.value.data == NULL) {
|
1324
|
+
conf->cache_key = prev->cache_key;
|
1325
|
+
}
|
1326
|
+
|
1327
|
+
#endif
|
1328
|
+
|
1329
|
+
ngx_conf_merge_value(conf->upstream.pass_request_headers,
|
1330
|
+
prev->upstream.pass_request_headers, 1);
|
1331
|
+
ngx_conf_merge_value(conf->upstream.pass_request_body,
|
1332
|
+
prev->upstream.pass_request_body, 1);
|
1333
|
+
|
1334
|
+
ngx_conf_merge_value(conf->upstream.intercept_errors,
|
1335
|
+
prev->upstream.intercept_errors, 0);
|
1336
|
+
|
1337
|
+
ngx_conf_merge_str_value(conf->uwsgi_string, prev->uwsgi_string, "");
|
1338
|
+
|
1339
|
+
hash.max_size = 512;
|
1340
|
+
hash.bucket_size = ngx_align(64, ngx_cacheline_size);
|
1341
|
+
hash.name = "uwsgi_hide_headers_hash";
|
1342
|
+
|
1343
|
+
if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
|
1344
|
+
&prev->upstream, ngx_http_uwsgi_hide_headers, &hash)
|
1345
|
+
!= NGX_OK)
|
1346
|
+
{
|
1347
|
+
return NGX_CONF_ERROR;
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
if (conf->upstream.upstream == NULL) {
|
1351
|
+
conf->upstream.upstream = prev->upstream.upstream;
|
1352
|
+
}
|
1353
|
+
|
1354
|
+
if (conf->uwsgi_lengths == NULL) {
|
1355
|
+
conf->uwsgi_lengths = prev->uwsgi_lengths;
|
1356
|
+
conf->uwsgi_values = prev->uwsgi_values;
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
if (conf->upstream.upstream || conf->uwsgi_lengths) {
|
1360
|
+
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
1361
|
+
if (clcf->handler == NULL && clcf->lmt_excpt) {
|
1362
|
+
clcf->handler = ngx_http_uwsgi_handler;
|
1363
|
+
}
|
1364
|
+
}
|
1365
|
+
|
1366
|
+
ngx_conf_merge_uint_value(conf->modifier1, prev->modifier1, 0);
|
1367
|
+
ngx_conf_merge_uint_value(conf->modifier2, prev->modifier2, 0);
|
1368
|
+
|
1369
|
+
if (ngx_http_uwsgi_merge_params(cf, conf, prev) != NGX_OK) {
|
1370
|
+
return NGX_CONF_ERROR;
|
1371
|
+
}
|
1372
|
+
|
1373
|
+
return NGX_CONF_OK;
|
1374
|
+
}
|
1375
|
+
|
1376
|
+
|
1377
|
+
static ngx_int_t
|
1378
|
+
ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
|
1379
|
+
ngx_http_uwsgi_loc_conf_t *prev)
|
1380
|
+
{
|
1381
|
+
u_char *p;
|
1382
|
+
size_t size;
|
1383
|
+
uintptr_t *code;
|
1384
|
+
ngx_uint_t i, nsrc;
|
1385
|
+
ngx_array_t headers_names;
|
1386
|
+
#if (NGX_HTTP_CACHE)
|
1387
|
+
ngx_array_t params_merged;
|
1388
|
+
#endif
|
1389
|
+
ngx_keyval_t *src;
|
1390
|
+
ngx_hash_key_t *hk;
|
1391
|
+
ngx_hash_init_t hash;
|
1392
|
+
ngx_http_script_compile_t sc;
|
1393
|
+
ngx_http_script_copy_code_t *copy;
|
1394
|
+
|
1395
|
+
if (conf->params_source == NULL) {
|
1396
|
+
conf->params_source = prev->params_source;
|
1397
|
+
|
1398
|
+
if (prev->headers_hash.buckets
|
1399
|
+
#if (NGX_HTTP_CACHE)
|
1400
|
+
&& ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL))
|
1401
|
+
#endif
|
1402
|
+
)
|
1403
|
+
{
|
1404
|
+
conf->flushes = prev->flushes;
|
1405
|
+
conf->params_len = prev->params_len;
|
1406
|
+
conf->params = prev->params;
|
1407
|
+
conf->headers_hash = prev->headers_hash;
|
1408
|
+
conf->header_params = prev->header_params;
|
1409
|
+
|
1410
|
+
return NGX_OK;
|
1411
|
+
}
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
if (conf->params_source == NULL
|
1415
|
+
#if (NGX_HTTP_CACHE)
|
1416
|
+
&& (conf->upstream.cache == NULL)
|
1417
|
+
#endif
|
1418
|
+
)
|
1419
|
+
{
|
1420
|
+
conf->headers_hash.buckets = (void *) 1;
|
1421
|
+
return NGX_OK;
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
conf->params_len = ngx_array_create(cf->pool, 64, 1);
|
1425
|
+
if (conf->params_len == NULL) {
|
1426
|
+
return NGX_ERROR;
|
1427
|
+
}
|
1428
|
+
|
1429
|
+
conf->params = ngx_array_create(cf->pool, 512, 1);
|
1430
|
+
if (conf->params == NULL) {
|
1431
|
+
return NGX_ERROR;
|
1432
|
+
}
|
1433
|
+
|
1434
|
+
if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
|
1435
|
+
!= NGX_OK)
|
1436
|
+
{
|
1437
|
+
return NGX_ERROR;
|
1438
|
+
}
|
1439
|
+
|
1440
|
+
if (conf->params_source) {
|
1441
|
+
src = conf->params_source->elts;
|
1442
|
+
nsrc = conf->params_source->nelts;
|
1443
|
+
|
1444
|
+
} else {
|
1445
|
+
src = NULL;
|
1446
|
+
nsrc = 0;
|
1447
|
+
}
|
1448
|
+
|
1449
|
+
#if (NGX_HTTP_CACHE)
|
1450
|
+
|
1451
|
+
if (conf->upstream.cache) {
|
1452
|
+
ngx_keyval_t *h, *s;
|
1453
|
+
|
1454
|
+
if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t))
|
1455
|
+
!= NGX_OK)
|
1456
|
+
{
|
1457
|
+
return NGX_ERROR;
|
1458
|
+
}
|
1459
|
+
|
1460
|
+
for (i = 0; i < nsrc; i++) {
|
1461
|
+
|
1462
|
+
s = ngx_array_push(¶ms_merged);
|
1463
|
+
if (s == NULL) {
|
1464
|
+
return NGX_ERROR;
|
1465
|
+
}
|
1466
|
+
|
1467
|
+
*s = src[i];
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
h = ngx_http_uwsgi_cache_headers;
|
1471
|
+
|
1472
|
+
while (h->key.len) {
|
1473
|
+
|
1474
|
+
src = params_merged.elts;
|
1475
|
+
nsrc = params_merged.nelts;
|
1476
|
+
|
1477
|
+
for (i = 0; i < nsrc; i++) {
|
1478
|
+
if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) {
|
1479
|
+
goto next;
|
1480
|
+
}
|
1481
|
+
}
|
1482
|
+
|
1483
|
+
s = ngx_array_push(¶ms_merged);
|
1484
|
+
if (s == NULL) {
|
1485
|
+
return NGX_ERROR;
|
1486
|
+
}
|
1487
|
+
|
1488
|
+
*s = *h;
|
1489
|
+
|
1490
|
+
next:
|
1491
|
+
|
1492
|
+
h++;
|
1493
|
+
}
|
1494
|
+
|
1495
|
+
src = params_merged.elts;
|
1496
|
+
nsrc = params_merged.nelts;
|
1497
|
+
}
|
1498
|
+
|
1499
|
+
#endif
|
1500
|
+
|
1501
|
+
for (i = 0; i < nsrc; i++) {
|
1502
|
+
|
1503
|
+
if (src[i].key.len > sizeof("HTTP_") - 1
|
1504
|
+
&& ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0)
|
1505
|
+
{
|
1506
|
+
hk = ngx_array_push(&headers_names);
|
1507
|
+
if (hk == NULL) {
|
1508
|
+
return NGX_ERROR;
|
1509
|
+
}
|
1510
|
+
|
1511
|
+
hk->key.len = src[i].key.len - 5;
|
1512
|
+
hk->key.data = src[i].key.data + 5;
|
1513
|
+
hk->key_hash = ngx_hash_key_lc(hk->key.data, hk->key.len);
|
1514
|
+
hk->value = (void *) 1;
|
1515
|
+
|
1516
|
+
if (src[i].value.len == 0) {
|
1517
|
+
continue;
|
1518
|
+
}
|
1519
|
+
}
|
1520
|
+
|
1521
|
+
copy = ngx_array_push_n(conf->params_len,
|
1522
|
+
sizeof(ngx_http_script_copy_code_t));
|
1523
|
+
if (copy == NULL) {
|
1524
|
+
return NGX_ERROR;
|
1525
|
+
}
|
1526
|
+
|
1527
|
+
copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
|
1528
|
+
copy->len = src[i].key.len;
|
1529
|
+
|
1530
|
+
|
1531
|
+
size = (sizeof(ngx_http_script_copy_code_t)
|
1532
|
+
+ src[i].key.len + sizeof(uintptr_t) - 1)
|
1533
|
+
& ~(sizeof(uintptr_t) - 1);
|
1534
|
+
|
1535
|
+
copy = ngx_array_push_n(conf->params, size);
|
1536
|
+
if (copy == NULL) {
|
1537
|
+
return NGX_ERROR;
|
1538
|
+
}
|
1539
|
+
|
1540
|
+
copy->code = ngx_http_script_copy_code;
|
1541
|
+
copy->len = src[i].key.len;
|
1542
|
+
|
1543
|
+
p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t);
|
1544
|
+
ngx_memcpy(p, src[i].key.data, src[i].key.len);
|
1545
|
+
|
1546
|
+
|
1547
|
+
ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
1548
|
+
|
1549
|
+
sc.cf = cf;
|
1550
|
+
sc.source = &src[i].value;
|
1551
|
+
sc.flushes = &conf->flushes;
|
1552
|
+
sc.lengths = &conf->params_len;
|
1553
|
+
sc.values = &conf->params;
|
1554
|
+
|
1555
|
+
if (ngx_http_script_compile(&sc) != NGX_OK) {
|
1556
|
+
return NGX_ERROR;
|
1557
|
+
}
|
1558
|
+
|
1559
|
+
code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
|
1560
|
+
if (code == NULL) {
|
1561
|
+
return NGX_ERROR;
|
1562
|
+
}
|
1563
|
+
|
1564
|
+
*code = (uintptr_t) NULL;
|
1565
|
+
|
1566
|
+
|
1567
|
+
code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
|
1568
|
+
if (code == NULL) {
|
1569
|
+
return NGX_ERROR;
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
*code = (uintptr_t) NULL;
|
1573
|
+
}
|
1574
|
+
|
1575
|
+
code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
|
1576
|
+
if (code == NULL) {
|
1577
|
+
return NGX_ERROR;
|
1578
|
+
}
|
1579
|
+
|
1580
|
+
*code = (uintptr_t) NULL;
|
1581
|
+
|
1582
|
+
conf->header_params = headers_names.nelts;
|
1583
|
+
|
1584
|
+
hash.hash = &conf->headers_hash;
|
1585
|
+
hash.key = ngx_hash_key_lc;
|
1586
|
+
hash.max_size = 512;
|
1587
|
+
hash.bucket_size = 64;
|
1588
|
+
hash.name = "uwsgi_params_hash";
|
1589
|
+
hash.pool = cf->pool;
|
1590
|
+
hash.temp_pool = NULL;
|
1591
|
+
|
1592
|
+
return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts);
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
|
1596
|
+
static char *
|
1597
|
+
ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
1598
|
+
{
|
1599
|
+
ngx_http_uwsgi_loc_conf_t *uwcf = conf;
|
1600
|
+
|
1601
|
+
ngx_url_t u;
|
1602
|
+
ngx_str_t *value, *url;
|
1603
|
+
ngx_uint_t n;
|
1604
|
+
ngx_http_core_loc_conf_t *clcf;
|
1605
|
+
ngx_http_script_compile_t sc;
|
1606
|
+
|
1607
|
+
if (uwcf->upstream.upstream || uwcf->uwsgi_lengths) {
|
1608
|
+
return "is duplicate";
|
1609
|
+
}
|
1610
|
+
|
1611
|
+
clcf = ngx_http_conf_get_module_loc_conf (cf, ngx_http_core_module);
|
1612
|
+
clcf->handler = ngx_http_uwsgi_handler;
|
1613
|
+
|
1614
|
+
value = cf->args->elts;
|
1615
|
+
|
1616
|
+
url = &value[1];
|
1617
|
+
|
1618
|
+
n = ngx_http_script_variables_count(url);
|
1619
|
+
|
1620
|
+
if (n) {
|
1621
|
+
|
1622
|
+
ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
1623
|
+
|
1624
|
+
sc.cf = cf;
|
1625
|
+
sc.source = url;
|
1626
|
+
sc.lengths = &uwcf->uwsgi_lengths;
|
1627
|
+
sc.values = &uwcf->uwsgi_values;
|
1628
|
+
sc.variables = n;
|
1629
|
+
sc.complete_lengths = 1;
|
1630
|
+
sc.complete_values = 1;
|
1631
|
+
|
1632
|
+
if (ngx_http_script_compile(&sc) != NGX_OK) {
|
1633
|
+
return NGX_CONF_ERROR;
|
1634
|
+
}
|
1635
|
+
|
1636
|
+
return NGX_CONF_OK;
|
1637
|
+
}
|
1638
|
+
|
1639
|
+
ngx_memzero(&u, sizeof(ngx_url_t));
|
1640
|
+
|
1641
|
+
u.url = value[1];
|
1642
|
+
u.no_resolve = 1;
|
1643
|
+
|
1644
|
+
uwcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
|
1645
|
+
if (uwcf->upstream.upstream == NULL) {
|
1646
|
+
return NGX_CONF_ERROR;
|
1647
|
+
}
|
1648
|
+
|
1649
|
+
if (clcf->name.data[clcf->name.len - 1] == '/') {
|
1650
|
+
clcf->auto_redirect = 1;
|
1651
|
+
}
|
1652
|
+
|
1653
|
+
return NGX_CONF_OK;
|
1654
|
+
}
|
1655
|
+
|
1656
|
+
|
1657
|
+
static char *
|
1658
|
+
ngx_http_uwsgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
1659
|
+
{
|
1660
|
+
ngx_http_uwsgi_loc_conf_t *uwcf = conf;
|
1661
|
+
|
1662
|
+
ngx_str_t *value;
|
1663
|
+
ngx_http_script_compile_t sc;
|
1664
|
+
|
1665
|
+
if (uwcf->upstream.store != NGX_CONF_UNSET || uwcf->upstream.store_lengths)
|
1666
|
+
{
|
1667
|
+
return "is duplicate";
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
value = cf->args->elts;
|
1671
|
+
|
1672
|
+
if (ngx_strcmp(value[1].data, "off") == 0) {
|
1673
|
+
uwcf->upstream.store = 0;
|
1674
|
+
return NGX_CONF_OK;
|
1675
|
+
}
|
1676
|
+
|
1677
|
+
#if (NGX_HTTP_CACHE)
|
1678
|
+
|
1679
|
+
if (uwcf->upstream.cache != NGX_CONF_UNSET_PTR
|
1680
|
+
&& uwcf->upstream.cache != NULL)
|
1681
|
+
{
|
1682
|
+
return "is incompatible with \"uwsgi_cache\"";
|
1683
|
+
}
|
1684
|
+
|
1685
|
+
#endif
|
1686
|
+
|
1687
|
+
if (ngx_strcmp(value[1].data, "on") == 0) {
|
1688
|
+
uwcf->upstream.store = 1;
|
1689
|
+
return NGX_CONF_OK;
|
1690
|
+
}
|
1691
|
+
|
1692
|
+
/* include the terminating '\0' into script */
|
1693
|
+
value[1].len++;
|
1694
|
+
|
1695
|
+
ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
1696
|
+
|
1697
|
+
sc.cf = cf;
|
1698
|
+
sc.source = &value[1];
|
1699
|
+
sc.lengths = &uwcf->upstream.store_lengths;
|
1700
|
+
sc.values = &uwcf->upstream.store_values;
|
1701
|
+
sc.variables = ngx_http_script_variables_count(&value[1]);;
|
1702
|
+
sc.complete_lengths = 1;
|
1703
|
+
sc.complete_values = 1;
|
1704
|
+
|
1705
|
+
if (ngx_http_script_compile(&sc) != NGX_OK) {
|
1706
|
+
return NGX_CONF_ERROR;
|
1707
|
+
}
|
1708
|
+
|
1709
|
+
return NGX_CONF_OK;
|
1710
|
+
}
|
1711
|
+
|
1712
|
+
|
1713
|
+
#if (NGX_HTTP_CACHE)
|
1714
|
+
|
1715
|
+
static char *
|
1716
|
+
ngx_http_uwsgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
1717
|
+
{
|
1718
|
+
ngx_http_uwsgi_loc_conf_t *uwcf = conf;
|
1719
|
+
|
1720
|
+
ngx_str_t *value;
|
1721
|
+
|
1722
|
+
value = cf->args->elts;
|
1723
|
+
|
1724
|
+
if (uwcf->upstream.cache != NGX_CONF_UNSET_PTR) {
|
1725
|
+
return "is duplicate";
|
1726
|
+
}
|
1727
|
+
|
1728
|
+
if (ngx_strcmp(value[1].data, "off") == 0) {
|
1729
|
+
uwcf->upstream.cache = NULL;
|
1730
|
+
return NGX_CONF_OK;
|
1731
|
+
}
|
1732
|
+
|
1733
|
+
if (uwcf->upstream.store > 0 || uwcf->upstream.store_lengths) {
|
1734
|
+
return "is incompatible with \"uwsgi_store\"";
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
uwcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0,
|
1738
|
+
&ngx_http_uwsgi_module);
|
1739
|
+
if (uwcf->upstream.cache == NULL) {
|
1740
|
+
return NGX_CONF_ERROR;
|
1741
|
+
}
|
1742
|
+
|
1743
|
+
return NGX_CONF_OK;
|
1744
|
+
}
|
1745
|
+
|
1746
|
+
|
1747
|
+
static char *
|
1748
|
+
ngx_http_uwsgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
1749
|
+
{
|
1750
|
+
ngx_http_uwsgi_loc_conf_t *uwcf = conf;
|
1751
|
+
|
1752
|
+
ngx_str_t *value;
|
1753
|
+
ngx_http_compile_complex_value_t ccv;
|
1754
|
+
|
1755
|
+
value = cf->args->elts;
|
1756
|
+
|
1757
|
+
if (uwcf->cache_key.value.len) {
|
1758
|
+
return "is duplicate";
|
1759
|
+
}
|
1760
|
+
|
1761
|
+
ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
1762
|
+
|
1763
|
+
ccv.cf = cf;
|
1764
|
+
ccv.value = &value[1];
|
1765
|
+
ccv.complex_value = &uwcf->cache_key;
|
1766
|
+
|
1767
|
+
if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
1768
|
+
return NGX_CONF_ERROR;
|
1769
|
+
}
|
1770
|
+
|
1771
|
+
return NGX_CONF_OK;
|
1772
|
+
}
|
1773
|
+
|
1774
|
+
#endif
|