nginxtra 1.0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (363) hide show
  1. data/VERSION +1 -0
  2. data/bin/nginxtra +5 -0
  3. data/lib/nginxtra.rb +12 -0
  4. data/lib/nginxtra/action.rb +36 -0
  5. data/lib/nginxtra/actions/compile.rb +60 -0
  6. data/lib/nginxtra/actions/install.rb +99 -0
  7. data/lib/nginxtra/actions/reload.rb +14 -0
  8. data/lib/nginxtra/actions/restart.rb +15 -0
  9. data/lib/nginxtra/actions/start.rb +53 -0
  10. data/lib/nginxtra/actions/status.rb +31 -0
  11. data/lib/nginxtra/actions/stop.rb +14 -0
  12. data/lib/nginxtra/cli.rb +77 -0
  13. data/lib/nginxtra/config.rb +339 -0
  14. data/lib/nginxtra/error.rb +13 -0
  15. data/lib/nginxtra/status.rb +57 -0
  16. data/src/nginx/CHANGES +5630 -0
  17. data/src/nginx/CHANGES.ru +5716 -0
  18. data/src/nginx/LICENSE +25 -0
  19. data/src/nginx/README +3 -0
  20. data/src/nginx/auto/cc/acc +15 -0
  21. data/src/nginx/auto/cc/bcc +72 -0
  22. data/src/nginx/auto/cc/ccc +46 -0
  23. data/src/nginx/auto/cc/conf +189 -0
  24. data/src/nginx/auto/cc/gcc +183 -0
  25. data/src/nginx/auto/cc/icc +121 -0
  26. data/src/nginx/auto/cc/msvc +138 -0
  27. data/src/nginx/auto/cc/name +101 -0
  28. data/src/nginx/auto/cc/owc +104 -0
  29. data/src/nginx/auto/cc/sunc +158 -0
  30. data/src/nginx/auto/define +12 -0
  31. data/src/nginx/auto/endianess +45 -0
  32. data/src/nginx/auto/feature +123 -0
  33. data/src/nginx/auto/have +12 -0
  34. data/src/nginx/auto/have_headers +12 -0
  35. data/src/nginx/auto/headers +13 -0
  36. data/src/nginx/auto/include +61 -0
  37. data/src/nginx/auto/init +51 -0
  38. data/src/nginx/auto/install +184 -0
  39. data/src/nginx/auto/lib/conf +83 -0
  40. data/src/nginx/auto/lib/geoip/conf +79 -0
  41. data/src/nginx/auto/lib/google-perftools/conf +45 -0
  42. data/src/nginx/auto/lib/libatomic/conf +43 -0
  43. data/src/nginx/auto/lib/libatomic/make +14 -0
  44. data/src/nginx/auto/lib/libgd/conf +83 -0
  45. data/src/nginx/auto/lib/libxslt/conf +156 -0
  46. data/src/nginx/auto/lib/make +32 -0
  47. data/src/nginx/auto/lib/md5/conf +103 -0
  48. data/src/nginx/auto/lib/md5/make +96 -0
  49. data/src/nginx/auto/lib/md5/makefile.bcc +22 -0
  50. data/src/nginx/auto/lib/md5/makefile.msvc +22 -0
  51. data/src/nginx/auto/lib/md5/makefile.owc +11 -0
  52. data/src/nginx/auto/lib/openssl/conf +74 -0
  53. data/src/nginx/auto/lib/openssl/make +67 -0
  54. data/src/nginx/auto/lib/openssl/makefile.bcc +18 -0
  55. data/src/nginx/auto/lib/openssl/makefile.msvc +14 -0
  56. data/src/nginx/auto/lib/pcre/conf +180 -0
  57. data/src/nginx/auto/lib/pcre/make +64 -0
  58. data/src/nginx/auto/lib/pcre/makefile.bcc +26 -0
  59. data/src/nginx/auto/lib/pcre/makefile.msvc +22 -0
  60. data/src/nginx/auto/lib/pcre/makefile.owc +24 -0
  61. data/src/nginx/auto/lib/perl/conf +60 -0
  62. data/src/nginx/auto/lib/perl/make +36 -0
  63. data/src/nginx/auto/lib/sha1/conf +79 -0
  64. data/src/nginx/auto/lib/sha1/make +96 -0
  65. data/src/nginx/auto/lib/sha1/makefile.bcc +22 -0
  66. data/src/nginx/auto/lib/sha1/makefile.msvc +22 -0
  67. data/src/nginx/auto/lib/sha1/makefile.owc +11 -0
  68. data/src/nginx/auto/lib/test +40 -0
  69. data/src/nginx/auto/lib/zlib/conf +76 -0
  70. data/src/nginx/auto/lib/zlib/make +114 -0
  71. data/src/nginx/auto/lib/zlib/makefile.bcc +15 -0
  72. data/src/nginx/auto/lib/zlib/makefile.msvc +14 -0
  73. data/src/nginx/auto/lib/zlib/makefile.owc +14 -0
  74. data/src/nginx/auto/lib/zlib/patch.zlib.h +10 -0
  75. data/src/nginx/auto/make +417 -0
  76. data/src/nginx/auto/modules +479 -0
  77. data/src/nginx/auto/nohave +12 -0
  78. data/src/nginx/auto/options +490 -0
  79. data/src/nginx/auto/os/conf +105 -0
  80. data/src/nginx/auto/os/darwin +116 -0
  81. data/src/nginx/auto/os/freebsd +136 -0
  82. data/src/nginx/auto/os/linux +152 -0
  83. data/src/nginx/auto/os/solaris +60 -0
  84. data/src/nginx/auto/os/win32 +29 -0
  85. data/src/nginx/auto/sources +518 -0
  86. data/src/nginx/auto/stubs +8 -0
  87. data/src/nginx/auto/summary +114 -0
  88. data/src/nginx/auto/types/sizeof +83 -0
  89. data/src/nginx/auto/types/typedef +77 -0
  90. data/src/nginx/auto/types/uintptr_t +42 -0
  91. data/src/nginx/auto/types/value +12 -0
  92. data/src/nginx/auto/unix +719 -0
  93. data/src/nginx/conf/fastcgi.conf +24 -0
  94. data/src/nginx/conf/fastcgi_params +23 -0
  95. data/src/nginx/conf/koi-utf +109 -0
  96. data/src/nginx/conf/koi-win +103 -0
  97. data/src/nginx/conf/mime.types +80 -0
  98. data/src/nginx/conf/nginx.conf +118 -0
  99. data/src/nginx/conf/scgi_params +15 -0
  100. data/src/nginx/conf/uwsgi_params +15 -0
  101. data/src/nginx/conf/win-utf +126 -0
  102. data/src/nginx/configure +108 -0
  103. data/src/nginx/contrib/README +15 -0
  104. data/src/nginx/contrib/geo2nginx.pl +58 -0
  105. data/src/nginx/contrib/unicode2nginx/koi-utf +131 -0
  106. data/src/nginx/contrib/unicode2nginx/unicode-to-nginx.pl +45 -0
  107. data/src/nginx/contrib/unicode2nginx/win-utf +130 -0
  108. data/src/nginx/html/50x.html +18 -0
  109. data/src/nginx/html/index.html +8 -0
  110. data/src/nginx/man/nginx.8 +202 -0
  111. data/src/nginx/src/core/nginx.c +1333 -0
  112. data/src/nginx/src/core/nginx.h +20 -0
  113. data/src/nginx/src/core/ngx_array.c +147 -0
  114. data/src/nginx/src/core/ngx_array.h +53 -0
  115. data/src/nginx/src/core/ngx_buf.c +218 -0
  116. data/src/nginx/src/core/ngx_buf.h +162 -0
  117. data/src/nginx/src/core/ngx_conf_file.c +1506 -0
  118. data/src/nginx/src/core/ngx_conf_file.h +348 -0
  119. data/src/nginx/src/core/ngx_config.h +134 -0
  120. data/src/nginx/src/core/ngx_connection.c +1074 -0
  121. data/src/nginx/src/core/ngx_connection.h +195 -0
  122. data/src/nginx/src/core/ngx_core.h +95 -0
  123. data/src/nginx/src/core/ngx_cpuinfo.c +139 -0
  124. data/src/nginx/src/core/ngx_crc.h +39 -0
  125. data/src/nginx/src/core/ngx_crc32.c +129 -0
  126. data/src/nginx/src/core/ngx_crc32.h +79 -0
  127. data/src/nginx/src/core/ngx_crypt.c +238 -0
  128. data/src/nginx/src/core/ngx_crypt.h +20 -0
  129. data/src/nginx/src/core/ngx_cycle.c +1379 -0
  130. data/src/nginx/src/core/ngx_cycle.h +142 -0
  131. data/src/nginx/src/core/ngx_file.c +993 -0
  132. data/src/nginx/src/core/ngx_file.h +151 -0
  133. data/src/nginx/src/core/ngx_hash.c +976 -0
  134. data/src/nginx/src/core/ngx_hash.h +122 -0
  135. data/src/nginx/src/core/ngx_inet.c +1008 -0
  136. data/src/nginx/src/core/ngx_inet.h +120 -0
  137. data/src/nginx/src/core/ngx_list.c +71 -0
  138. data/src/nginx/src/core/ngx_list.h +83 -0
  139. data/src/nginx/src/core/ngx_log.c +459 -0
  140. data/src/nginx/src/core/ngx_log.h +250 -0
  141. data/src/nginx/src/core/ngx_md5.c +289 -0
  142. data/src/nginx/src/core/ngx_md5.h +60 -0
  143. data/src/nginx/src/core/ngx_murmurhash.c +50 -0
  144. data/src/nginx/src/core/ngx_murmurhash.h +19 -0
  145. data/src/nginx/src/core/ngx_open_file_cache.c +882 -0
  146. data/src/nginx/src/core/ngx_open_file_cache.h +119 -0
  147. data/src/nginx/src/core/ngx_output_chain.c +673 -0
  148. data/src/nginx/src/core/ngx_palloc.c +433 -0
  149. data/src/nginx/src/core/ngx_palloc.h +95 -0
  150. data/src/nginx/src/core/ngx_parse.c +249 -0
  151. data/src/nginx/src/core/ngx_parse.h +24 -0
  152. data/src/nginx/src/core/ngx_queue.c +80 -0
  153. data/src/nginx/src/core/ngx_queue.h +112 -0
  154. data/src/nginx/src/core/ngx_radix_tree.c +291 -0
  155. data/src/nginx/src/core/ngx_radix_tree.h +46 -0
  156. data/src/nginx/src/core/ngx_rbtree.c +383 -0
  157. data/src/nginx/src/core/ngx_rbtree.h +84 -0
  158. data/src/nginx/src/core/ngx_regex.c +206 -0
  159. data/src/nginx/src/core/ngx_regex.h +56 -0
  160. data/src/nginx/src/core/ngx_resolver.c +2201 -0
  161. data/src/nginx/src/core/ngx_resolver.h +149 -0
  162. data/src/nginx/src/core/ngx_sha1.h +31 -0
  163. data/src/nginx/src/core/ngx_shmtx.c +284 -0
  164. data/src/nginx/src/core/ngx_shmtx.h +38 -0
  165. data/src/nginx/src/core/ngx_slab.c +701 -0
  166. data/src/nginx/src/core/ngx_slab.h +54 -0
  167. data/src/nginx/src/core/ngx_spinlock.c +53 -0
  168. data/src/nginx/src/core/ngx_string.c +1837 -0
  169. data/src/nginx/src/core/ngx_string.h +231 -0
  170. data/src/nginx/src/core/ngx_times.c +407 -0
  171. data/src/nginx/src/core/ngx_times.h +51 -0
  172. data/src/nginx/src/event/modules/ngx_aio_module.c +171 -0
  173. data/src/nginx/src/event/modules/ngx_devpoll_module.c +569 -0
  174. data/src/nginx/src/event/modules/ngx_epoll_module.c +833 -0
  175. data/src/nginx/src/event/modules/ngx_eventport_module.c +602 -0
  176. data/src/nginx/src/event/modules/ngx_kqueue_module.c +785 -0
  177. data/src/nginx/src/event/modules/ngx_poll_module.c +443 -0
  178. data/src/nginx/src/event/modules/ngx_rtsig_module.c +735 -0
  179. data/src/nginx/src/event/modules/ngx_select_module.c +435 -0
  180. data/src/nginx/src/event/modules/ngx_win32_select_module.c +400 -0
  181. data/src/nginx/src/event/ngx_event.c +1275 -0
  182. data/src/nginx/src/event/ngx_event.h +573 -0
  183. data/src/nginx/src/event/ngx_event_accept.c +428 -0
  184. data/src/nginx/src/event/ngx_event_busy_lock.c +286 -0
  185. data/src/nginx/src/event/ngx_event_busy_lock.h +65 -0
  186. data/src/nginx/src/event/ngx_event_connect.c +258 -0
  187. data/src/nginx/src/event/ngx_event_connect.h +76 -0
  188. data/src/nginx/src/event/ngx_event_mutex.c +70 -0
  189. data/src/nginx/src/event/ngx_event_openssl.c +2382 -0
  190. data/src/nginx/src/event/ngx_event_openssl.h +162 -0
  191. data/src/nginx/src/event/ngx_event_pipe.c +996 -0
  192. data/src/nginx/src/event/ngx_event_pipe.h +95 -0
  193. data/src/nginx/src/event/ngx_event_posted.c +173 -0
  194. data/src/nginx/src/event/ngx_event_posted.h +75 -0
  195. data/src/nginx/src/event/ngx_event_timer.c +159 -0
  196. data/src/nginx/src/event/ngx_event_timer.h +102 -0
  197. data/src/nginx/src/http/modules/ngx_http_access_module.c +384 -0
  198. data/src/nginx/src/http/modules/ngx_http_addition_filter_module.c +250 -0
  199. data/src/nginx/src/http/modules/ngx_http_auth_basic_module.c +478 -0
  200. data/src/nginx/src/http/modules/ngx_http_autoindex_module.c +701 -0
  201. data/src/nginx/src/http/modules/ngx_http_browser_module.c +713 -0
  202. data/src/nginx/src/http/modules/ngx_http_charset_filter_module.c +1681 -0
  203. data/src/nginx/src/http/modules/ngx_http_chunked_filter_module.c +242 -0
  204. data/src/nginx/src/http/modules/ngx_http_dav_module.c +1141 -0
  205. data/src/nginx/src/http/modules/ngx_http_degradation_module.c +243 -0
  206. data/src/nginx/src/http/modules/ngx_http_empty_gif_module.c +140 -0
  207. data/src/nginx/src/http/modules/ngx_http_fastcgi_module.c +2916 -0
  208. data/src/nginx/src/http/modules/ngx_http_flv_module.c +254 -0
  209. data/src/nginx/src/http/modules/ngx_http_geo_module.c +1441 -0
  210. data/src/nginx/src/http/modules/ngx_http_geoip_module.c +671 -0
  211. data/src/nginx/src/http/modules/ngx_http_gzip_filter_module.c +1206 -0
  212. data/src/nginx/src/http/modules/ngx_http_gzip_static_module.c +299 -0
  213. data/src/nginx/src/http/modules/ngx_http_headers_filter_module.c +616 -0
  214. data/src/nginx/src/http/modules/ngx_http_image_filter_module.c +1489 -0
  215. data/src/nginx/src/http/modules/ngx_http_index_module.c +516 -0
  216. data/src/nginx/src/http/modules/ngx_http_limit_req_module.c +809 -0
  217. data/src/nginx/src/http/modules/ngx_http_limit_zone_module.c +553 -0
  218. data/src/nginx/src/http/modules/ngx_http_log_module.c +1357 -0
  219. data/src/nginx/src/http/modules/ngx_http_map_module.c +575 -0
  220. data/src/nginx/src/http/modules/ngx_http_memcached_module.c +624 -0
  221. data/src/nginx/src/http/modules/ngx_http_mp4_module.c +3000 -0
  222. data/src/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +143 -0
  223. data/src/nginx/src/http/modules/ngx_http_proxy_module.c +2831 -0
  224. data/src/nginx/src/http/modules/ngx_http_random_index_module.c +317 -0
  225. data/src/nginx/src/http/modules/ngx_http_range_filter_module.c +855 -0
  226. data/src/nginx/src/http/modules/ngx_http_realip_module.c +476 -0
  227. data/src/nginx/src/http/modules/ngx_http_referer_module.c +613 -0
  228. data/src/nginx/src/http/modules/ngx_http_rewrite_module.c +1019 -0
  229. data/src/nginx/src/http/modules/ngx_http_scgi_module.c +1714 -0
  230. data/src/nginx/src/http/modules/ngx_http_secure_link_module.c +355 -0
  231. data/src/nginx/src/http/modules/ngx_http_split_clients_module.c +242 -0
  232. data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.c +2913 -0
  233. data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.h +114 -0
  234. data/src/nginx/src/http/modules/ngx_http_ssl_module.c +652 -0
  235. data/src/nginx/src/http/modules/ngx_http_ssl_module.h +52 -0
  236. data/src/nginx/src/http/modules/ngx_http_static_module.c +278 -0
  237. data/src/nginx/src/http/modules/ngx_http_stub_status_module.c +144 -0
  238. data/src/nginx/src/http/modules/ngx_http_sub_filter_module.c +716 -0
  239. data/src/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +237 -0
  240. data/src/nginx/src/http/modules/ngx_http_userid_filter_module.c +846 -0
  241. data/src/nginx/src/http/modules/ngx_http_uwsgi_module.c +1774 -0
  242. data/src/nginx/src/http/modules/ngx_http_xslt_filter_module.c +984 -0
  243. data/src/nginx/src/http/modules/perl/Makefile.PL +42 -0
  244. data/src/nginx/src/http/modules/perl/nginx.pm +137 -0
  245. data/src/nginx/src/http/modules/perl/nginx.xs +986 -0
  246. data/src/nginx/src/http/modules/perl/ngx_http_perl_module.c +1076 -0
  247. data/src/nginx/src/http/modules/perl/ngx_http_perl_module.h +67 -0
  248. data/src/nginx/src/http/modules/perl/typemap +3 -0
  249. data/src/nginx/src/http/ngx_http.c +2073 -0
  250. data/src/nginx/src/http/ngx_http.h +160 -0
  251. data/src/nginx/src/http/ngx_http_busy_lock.c +307 -0
  252. data/src/nginx/src/http/ngx_http_busy_lock.h +54 -0
  253. data/src/nginx/src/http/ngx_http_cache.h +148 -0
  254. data/src/nginx/src/http/ngx_http_config.h +75 -0
  255. data/src/nginx/src/http/ngx_http_copy_filter_module.c +300 -0
  256. data/src/nginx/src/http/ngx_http_core_module.c +4736 -0
  257. data/src/nginx/src/http/ngx_http_core_module.h +541 -0
  258. data/src/nginx/src/http/ngx_http_file_cache.c +1715 -0
  259. data/src/nginx/src/http/ngx_http_header_filter_module.c +623 -0
  260. data/src/nginx/src/http/ngx_http_parse.c +1734 -0
  261. data/src/nginx/src/http/ngx_http_parse_time.c +276 -0
  262. data/src/nginx/src/http/ngx_http_postpone_filter_module.c +178 -0
  263. data/src/nginx/src/http/ngx_http_request.c +3181 -0
  264. data/src/nginx/src/http/ngx_http_request.h +573 -0
  265. data/src/nginx/src/http/ngx_http_request_body.c +644 -0
  266. data/src/nginx/src/http/ngx_http_script.c +1752 -0
  267. data/src/nginx/src/http/ngx_http_script.h +257 -0
  268. data/src/nginx/src/http/ngx_http_special_response.c +789 -0
  269. data/src/nginx/src/http/ngx_http_upstream.c +4555 -0
  270. data/src/nginx/src/http/ngx_http_upstream.h +350 -0
  271. data/src/nginx/src/http/ngx_http_upstream_round_robin.c +791 -0
  272. data/src/nginx/src/http/ngx_http_upstream_round_robin.h +85 -0
  273. data/src/nginx/src/http/ngx_http_variables.c +2053 -0
  274. data/src/nginx/src/http/ngx_http_variables.h +115 -0
  275. data/src/nginx/src/http/ngx_http_write_filter_module.c +315 -0
  276. data/src/nginx/src/mail/ngx_mail.c +542 -0
  277. data/src/nginx/src/mail/ngx_mail.h +407 -0
  278. data/src/nginx/src/mail/ngx_mail_auth_http_module.c +1452 -0
  279. data/src/nginx/src/mail/ngx_mail_core_module.c +553 -0
  280. data/src/nginx/src/mail/ngx_mail_handler.c +773 -0
  281. data/src/nginx/src/mail/ngx_mail_imap_handler.c +457 -0
  282. data/src/nginx/src/mail/ngx_mail_imap_module.c +253 -0
  283. data/src/nginx/src/mail/ngx_mail_imap_module.h +39 -0
  284. data/src/nginx/src/mail/ngx_mail_parse.c +885 -0
  285. data/src/nginx/src/mail/ngx_mail_pop3_handler.c +500 -0
  286. data/src/nginx/src/mail/ngx_mail_pop3_module.c +264 -0
  287. data/src/nginx/src/mail/ngx_mail_pop3_module.h +38 -0
  288. data/src/nginx/src/mail/ngx_mail_proxy_module.c +1089 -0
  289. data/src/nginx/src/mail/ngx_mail_smtp_handler.c +872 -0
  290. data/src/nginx/src/mail/ngx_mail_smtp_module.c +308 -0
  291. data/src/nginx/src/mail/ngx_mail_smtp_module.h +45 -0
  292. data/src/nginx/src/mail/ngx_mail_ssl_module.c +491 -0
  293. data/src/nginx/src/mail/ngx_mail_ssl_module.h +52 -0
  294. data/src/nginx/src/misc/ngx_cpp_test_module.cpp +27 -0
  295. data/src/nginx/src/misc/ngx_google_perftools_module.c +126 -0
  296. data/src/nginx/src/os/unix/ngx_aio_read.c +109 -0
  297. data/src/nginx/src/os/unix/ngx_aio_read_chain.c +78 -0
  298. data/src/nginx/src/os/unix/ngx_aio_write.c +109 -0
  299. data/src/nginx/src/os/unix/ngx_aio_write_chain.c +100 -0
  300. data/src/nginx/src/os/unix/ngx_alloc.c +90 -0
  301. data/src/nginx/src/os/unix/ngx_alloc.h +45 -0
  302. data/src/nginx/src/os/unix/ngx_atomic.h +311 -0
  303. data/src/nginx/src/os/unix/ngx_channel.c +258 -0
  304. data/src/nginx/src/os/unix/ngx_channel.h +34 -0
  305. data/src/nginx/src/os/unix/ngx_daemon.c +69 -0
  306. data/src/nginx/src/os/unix/ngx_darwin.h +20 -0
  307. data/src/nginx/src/os/unix/ngx_darwin_config.h +96 -0
  308. data/src/nginx/src/os/unix/ngx_darwin_init.c +166 -0
  309. data/src/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +366 -0
  310. data/src/nginx/src/os/unix/ngx_errno.c +87 -0
  311. data/src/nginx/src/os/unix/ngx_errno.h +68 -0
  312. data/src/nginx/src/os/unix/ngx_file_aio_read.c +208 -0
  313. data/src/nginx/src/os/unix/ngx_files.c +566 -0
  314. data/src/nginx/src/os/unix/ngx_files.h +343 -0
  315. data/src/nginx/src/os/unix/ngx_freebsd.h +24 -0
  316. data/src/nginx/src/os/unix/ngx_freebsd_config.h +119 -0
  317. data/src/nginx/src/os/unix/ngx_freebsd_init.c +259 -0
  318. data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +756 -0
  319. data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +122 -0
  320. data/src/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +436 -0
  321. data/src/nginx/src/os/unix/ngx_gcc_atomic_amd64.h +82 -0
  322. data/src/nginx/src/os/unix/ngx_gcc_atomic_ppc.h +155 -0
  323. data/src/nginx/src/os/unix/ngx_gcc_atomic_sparc64.h +82 -0
  324. data/src/nginx/src/os/unix/ngx_gcc_atomic_x86.h +127 -0
  325. data/src/nginx/src/os/unix/ngx_linux.h +18 -0
  326. data/src/nginx/src/os/unix/ngx_linux_aio_read.c +137 -0
  327. data/src/nginx/src/os/unix/ngx_linux_config.h +117 -0
  328. data/src/nginx/src/os/unix/ngx_linux_init.c +91 -0
  329. data/src/nginx/src/os/unix/ngx_linux_sendfile_chain.c +378 -0
  330. data/src/nginx/src/os/unix/ngx_os.h +84 -0
  331. data/src/nginx/src/os/unix/ngx_posix_config.h +153 -0
  332. data/src/nginx/src/os/unix/ngx_posix_init.c +124 -0
  333. data/src/nginx/src/os/unix/ngx_process.c +590 -0
  334. data/src/nginx/src/os/unix/ngx_process.h +87 -0
  335. data/src/nginx/src/os/unix/ngx_process_cycle.c +1390 -0
  336. data/src/nginx/src/os/unix/ngx_process_cycle.h +61 -0
  337. data/src/nginx/src/os/unix/ngx_pthread_thread.c +278 -0
  338. data/src/nginx/src/os/unix/ngx_readv_chain.c +258 -0
  339. data/src/nginx/src/os/unix/ngx_recv.c +180 -0
  340. data/src/nginx/src/os/unix/ngx_send.c +73 -0
  341. data/src/nginx/src/os/unix/ngx_setproctitle.c +135 -0
  342. data/src/nginx/src/os/unix/ngx_setproctitle.h +52 -0
  343. data/src/nginx/src/os/unix/ngx_shmem.c +126 -0
  344. data/src/nginx/src/os/unix/ngx_shmem.h +29 -0
  345. data/src/nginx/src/os/unix/ngx_socket.c +116 -0
  346. data/src/nginx/src/os/unix/ngx_socket.h +64 -0
  347. data/src/nginx/src/os/unix/ngx_solaris.h +16 -0
  348. data/src/nginx/src/os/unix/ngx_solaris_config.h +107 -0
  349. data/src/nginx/src/os/unix/ngx_solaris_init.c +75 -0
  350. data/src/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +251 -0
  351. data/src/nginx/src/os/unix/ngx_sunpro_amd64.il +43 -0
  352. data/src/nginx/src/os/unix/ngx_sunpro_atomic_sparc64.h +61 -0
  353. data/src/nginx/src/os/unix/ngx_sunpro_sparc64.il +36 -0
  354. data/src/nginx/src/os/unix/ngx_sunpro_x86.il +44 -0
  355. data/src/nginx/src/os/unix/ngx_thread.h +128 -0
  356. data/src/nginx/src/os/unix/ngx_time.c +104 -0
  357. data/src/nginx/src/os/unix/ngx_time.h +66 -0
  358. data/src/nginx/src/os/unix/ngx_udp_recv.c +115 -0
  359. data/src/nginx/src/os/unix/ngx_user.c +109 -0
  360. data/src/nginx/src/os/unix/ngx_user.h +24 -0
  361. data/src/nginx/src/os/unix/ngx_writev_chain.c +181 -0
  362. data/src/nginx/src/os/unix/rfork_thread.S +73 -0
  363. 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(&params_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(&params_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(&params_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