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