PageRenderTime 48ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/trafficserver-3.2.0/proxy/http/HttpConfig.h

#
C Header | 994 lines | 618 code | 138 blank | 238 comment | 3 complexity | 60227dd016839b9a55848b8d81a7dc9f MD5 | raw file
Possible License(s): Apache-2.0
  1. /** @file
  2. A brief file description
  3. @section license License
  4. Licensed to the Apache Software Foundation (ASF) under one
  5. or more contributor license agreements. See the NOTICE file
  6. distributed with this work for additional information
  7. regarding copyright ownership. The ASF licenses this file
  8. to you under the Apache License, Version 2.0 (the
  9. "License"); you may not use this file except in compliance
  10. with the License. You may obtain a copy of the License at
  11. http://www.apache.org/licenses/LICENSE-2.0
  12. Unless required by applicable law or agreed to in writing, software
  13. distributed under the License is distributed on an "AS IS" BASIS,
  14. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. See the License for the specific language governing permissions and
  16. limitations under the License.
  17. */
  18. /*************************** -*- Mod: C++ -*- ******************************
  19. HttpConfig.h
  20. Created On : Tue Oct 22 20:19:04 1996
  21. Description:
  22. Http Configurations
  23. ****************************************************************************/
  24. #ifndef _HttpConfig_h_
  25. #define _HttpConfig_h_
  26. #include <stdlib.h>
  27. #include <stdio.h>
  28. #ifdef HAVE_PCRE_PCRE_H
  29. #include <pcre/pcre.h>
  30. #else
  31. #include <pcre.h>
  32. #endif
  33. #ifdef HAVE_CTYPE_H
  34. #include <ctype.h>
  35. #endif
  36. #include "libts.h"
  37. #include "ProxyConfig.h"
  38. #include "P_RecProcess.h"
  39. /* Some defines that might be candidates for configurable settings later.
  40. */
  41. #define HTTP_SSN_TXN_MAX_USER_ARG 16 /* max number of user arguments for Transactions and Sessions */
  42. /* Instead of enumerating the stats in DynamicStats.h, each module needs
  43. to enumerate its stats separately and register them with librecords
  44. */
  45. enum
  46. {
  47. http_background_fill_current_count_stat,
  48. http_current_client_connections_stat,
  49. http_current_active_client_connections_stat,
  50. http_current_client_transactions_stat,
  51. http_total_incoming_connections_stat,
  52. http_current_parent_proxy_transactions_stat,
  53. http_current_icp_transactions_stat,
  54. http_current_server_transactions_stat,
  55. http_current_parent_proxy_raw_transactions_stat,
  56. http_current_icp_raw_transactions_stat,
  57. http_current_server_raw_transactions_stat,
  58. // Http Abort information (from HttpNetConnection)
  59. http_ua_msecs_counts_errors_pre_accept_hangups_stat,
  60. http_ua_msecs_counts_errors_empty_hangups_stat,
  61. http_ua_msecs_counts_errors_early_hangups_stat,
  62. // Http Total Connections Stats
  63. //
  64. // it is assumed that this inequality will always be satisifed:
  65. // http_total_client_connections_stat >=
  66. // http_total_client_connections_ipv4_stat +
  67. // http_total_client_connections_ipv6_stat
  68. http_total_client_connections_stat,
  69. http_total_client_connections_ipv4_stat,
  70. http_total_client_connections_ipv6_stat,
  71. http_total_server_connections_stat,
  72. http_total_parent_proxy_connections_stat,
  73. http_current_parent_proxy_connections_stat,
  74. http_current_server_connections_stat,
  75. http_current_cache_connections_stat,
  76. // Http K-A Stats
  77. http_transactions_per_client_con,
  78. http_transactions_per_server_con,
  79. http_transactions_per_parent_con,
  80. // Http Time Stuff
  81. http_client_connection_time_stat,
  82. http_parent_proxy_connection_time_stat,
  83. http_server_connection_time_stat,
  84. http_cache_connection_time_stat,
  85. // Transactional stats (originaly in proxy/HttpTransStats.h)
  86. http_incoming_requests_stat,
  87. http_outgoing_requests_stat,
  88. http_incoming_responses_stat,
  89. http_invalid_client_requests_stat,
  90. http_missing_host_hdr_stat,
  91. http_get_requests_stat,
  92. http_head_requests_stat,
  93. http_trace_requests_stat,
  94. http_options_requests_stat,
  95. http_post_requests_stat,
  96. http_put_requests_stat,
  97. http_push_requests_stat,
  98. http_delete_requests_stat,
  99. http_purge_requests_stat,
  100. http_connect_requests_stat,
  101. http_extension_method_requests_stat,
  102. http_completed_requests_stat,
  103. http_client_no_cache_requests_stat,
  104. // http_icp_requests_stat,
  105. // http_icp_invalid_responses_stat,
  106. // http_parent_proxy_requests_stat,
  107. // http_parent_invalid_responses_stat,
  108. // http_invalid_responses_stat,
  109. // http_retried_requests_stat,
  110. http_broken_server_connections_stat,
  111. http_cache_lookups_stat,
  112. http_cache_misses_stat,
  113. http_cache_writes_stat,
  114. http_cache_updates_stat,
  115. http_cache_deletes_stat,
  116. http_tunnels_stat,
  117. http_throttled_proxy_only_stat,
  118. // HTTP requests classified by IMS/no-cache/MSIE
  119. http_request_taxonomy_i0_n0_m0_stat,
  120. http_request_taxonomy_i1_n0_m0_stat,
  121. http_request_taxonomy_i0_n1_m0_stat,
  122. http_request_taxonomy_i1_n1_m0_stat,
  123. http_request_taxonomy_i0_n0_m1_stat,
  124. http_request_taxonomy_i1_n0_m1_stat,
  125. http_request_taxonomy_i0_n1_m1_stat,
  126. http_request_taxonomy_i1_n1_m1_stat,
  127. http_icp_suggested_lookups_stat,
  128. // document size stats
  129. http_user_agent_request_header_total_size_stat,
  130. http_user_agent_response_header_total_size_stat,
  131. http_user_agent_request_document_total_size_stat,
  132. http_user_agent_response_document_total_size_stat,
  133. http_origin_server_request_header_total_size_stat,
  134. http_origin_server_response_header_total_size_stat,
  135. http_origin_server_request_document_total_size_stat,
  136. http_origin_server_response_document_total_size_stat,
  137. http_parent_proxy_request_total_bytes_stat,
  138. http_parent_proxy_response_total_bytes_stat,
  139. http_pushed_response_header_total_size_stat,
  140. http_pushed_document_total_size_stat,
  141. http_background_fill_bytes_aborted_stat,
  142. http_background_fill_bytes_completed_stat,
  143. http_response_document_size_100_stat,
  144. http_response_document_size_1K_stat,
  145. http_response_document_size_3K_stat,
  146. http_response_document_size_5K_stat,
  147. http_response_document_size_10K_stat,
  148. http_response_document_size_1M_stat,
  149. http_response_document_size_inf_stat,
  150. http_request_document_size_100_stat,
  151. http_request_document_size_1K_stat,
  152. http_request_document_size_3K_stat,
  153. http_request_document_size_5K_stat,
  154. http_request_document_size_10K_stat,
  155. http_request_document_size_1M_stat,
  156. http_request_document_size_inf_stat,
  157. // connection speed stats
  158. http_user_agent_speed_bytes_per_sec_100_stat,
  159. http_user_agent_speed_bytes_per_sec_1K_stat,
  160. http_user_agent_speed_bytes_per_sec_10K_stat,
  161. http_user_agent_speed_bytes_per_sec_100K_stat,
  162. http_user_agent_speed_bytes_per_sec_1M_stat,
  163. http_user_agent_speed_bytes_per_sec_10M_stat,
  164. http_user_agent_speed_bytes_per_sec_100M_stat,
  165. http_origin_server_speed_bytes_per_sec_100_stat,
  166. http_origin_server_speed_bytes_per_sec_1K_stat,
  167. http_origin_server_speed_bytes_per_sec_10K_stat,
  168. http_origin_server_speed_bytes_per_sec_100K_stat,
  169. http_origin_server_speed_bytes_per_sec_1M_stat,
  170. http_origin_server_speed_bytes_per_sec_10M_stat,
  171. http_origin_server_speed_bytes_per_sec_100M_stat,
  172. // cache result stats
  173. http_cache_hit_fresh_stat,
  174. http_cache_hit_mem_fresh_stat,
  175. http_cache_hit_reval_stat,
  176. http_cache_hit_ims_stat,
  177. http_cache_hit_stale_served_stat,
  178. http_cache_miss_cold_stat,
  179. http_cache_miss_changed_stat,
  180. http_cache_miss_client_no_cache_stat,
  181. http_cache_miss_uncacheable_stat,
  182. http_cache_miss_ims_stat,
  183. http_cache_read_error_stat,
  184. // bandwidth savings stats
  185. http_tcp_hit_count_stat,
  186. http_tcp_hit_user_agent_bytes_stat,
  187. http_tcp_hit_origin_server_bytes_stat,
  188. http_tcp_miss_count_stat,
  189. http_tcp_miss_user_agent_bytes_stat,
  190. http_tcp_miss_origin_server_bytes_stat,
  191. http_tcp_expired_miss_count_stat,
  192. http_tcp_expired_miss_user_agent_bytes_stat,
  193. http_tcp_expired_miss_origin_server_bytes_stat,
  194. http_tcp_refresh_hit_count_stat,
  195. http_tcp_refresh_hit_user_agent_bytes_stat,
  196. http_tcp_refresh_hit_origin_server_bytes_stat,
  197. http_tcp_refresh_miss_count_stat,
  198. http_tcp_refresh_miss_user_agent_bytes_stat,
  199. http_tcp_refresh_miss_origin_server_bytes_stat,
  200. http_tcp_client_refresh_count_stat,
  201. http_tcp_client_refresh_user_agent_bytes_stat,
  202. http_tcp_client_refresh_origin_server_bytes_stat,
  203. http_tcp_ims_hit_count_stat,
  204. http_tcp_ims_hit_user_agent_bytes_stat,
  205. http_tcp_ims_hit_origin_server_bytes_stat,
  206. http_tcp_ims_miss_count_stat,
  207. http_tcp_ims_miss_user_agent_bytes_stat,
  208. http_tcp_ims_miss_origin_server_bytes_stat,
  209. http_err_client_abort_count_stat,
  210. http_err_client_abort_user_agent_bytes_stat,
  211. http_err_client_abort_origin_server_bytes_stat,
  212. http_err_connect_fail_count_stat,
  213. http_err_connect_fail_user_agent_bytes_stat,
  214. http_err_connect_fail_origin_server_bytes_stat,
  215. http_misc_count_stat,
  216. http_misc_user_agent_bytes_stat,
  217. http_misc_origin_server_bytes_stat,
  218. // http - time and count of transactions classified by client's point of view
  219. http_ua_msecs_counts_hit_fresh_stat,
  220. http_ua_msecs_counts_hit_fresh_process_stat,
  221. http_ua_msecs_counts_hit_reval_stat,
  222. http_ua_msecs_counts_hit_ims_stat,
  223. http_ua_msecs_counts_hit_stale_served_stat,
  224. http_ua_msecs_counts_miss_cold_stat,
  225. http_ua_msecs_counts_miss_changed_stat,
  226. http_ua_msecs_counts_miss_client_no_cache_stat,
  227. http_ua_msecs_counts_miss_uncacheable_stat,
  228. http_ua_msecs_counts_miss_ims_stat,
  229. http_ua_msecs_counts_errors_aborts_stat,
  230. http_ua_msecs_counts_errors_possible_aborts_stat,
  231. http_ua_msecs_counts_errors_connect_failed_stat,
  232. http_ua_msecs_counts_errors_other_stat,
  233. http_ua_msecs_counts_other_unclassified_stat,
  234. http_total_x_redirect_stat,
  235. // Times
  236. http_total_transactions_time_stat,
  237. http_total_transactions_think_time_stat,
  238. http_client_transaction_time_stat,
  239. http_client_write_time_stat,
  240. http_server_read_time_stat,
  241. http_icp_transaction_time_stat,
  242. http_icp_raw_transaction_time_stat,
  243. http_parent_proxy_transaction_time_stat,
  244. http_parent_proxy_raw_transaction_time_stat,
  245. http_server_transaction_time_stat,
  246. http_server_raw_transaction_time_stat,
  247. // Http cache errors
  248. http_cache_write_errors,
  249. http_cache_read_errors,
  250. // status code stats
  251. http_response_status_100_count_stat,
  252. http_response_status_101_count_stat,
  253. http_response_status_1xx_count_stat,
  254. http_response_status_200_count_stat,
  255. http_response_status_201_count_stat,
  256. http_response_status_202_count_stat,
  257. http_response_status_203_count_stat,
  258. http_response_status_204_count_stat,
  259. http_response_status_205_count_stat,
  260. http_response_status_206_count_stat,
  261. http_response_status_2xx_count_stat,
  262. http_response_status_300_count_stat,
  263. http_response_status_301_count_stat,
  264. http_response_status_302_count_stat,
  265. http_response_status_303_count_stat,
  266. http_response_status_304_count_stat,
  267. http_response_status_305_count_stat,
  268. http_response_status_307_count_stat,
  269. http_response_status_3xx_count_stat,
  270. http_response_status_400_count_stat,
  271. http_response_status_401_count_stat,
  272. http_response_status_402_count_stat,
  273. http_response_status_403_count_stat,
  274. http_response_status_404_count_stat,
  275. http_response_status_405_count_stat,
  276. http_response_status_406_count_stat,
  277. http_response_status_407_count_stat,
  278. http_response_status_408_count_stat,
  279. http_response_status_409_count_stat,
  280. http_response_status_410_count_stat,
  281. http_response_status_411_count_stat,
  282. http_response_status_412_count_stat,
  283. http_response_status_413_count_stat,
  284. http_response_status_414_count_stat,
  285. http_response_status_415_count_stat,
  286. http_response_status_416_count_stat,
  287. http_response_status_4xx_count_stat,
  288. http_response_status_500_count_stat,
  289. http_response_status_501_count_stat,
  290. http_response_status_502_count_stat,
  291. http_response_status_503_count_stat,
  292. http_response_status_504_count_stat,
  293. http_response_status_505_count_stat,
  294. http_response_status_5xx_count_stat,
  295. http_stat_count
  296. };
  297. extern RecRawStatBlock *http_rsb;
  298. /* Stats should only be accessed using these macros */
  299. #define HTTP_INCREMENT_DYN_STAT(x) RecIncrRawStat(http_rsb, mutex->thread_holding, (int) x, 1)
  300. #define HTTP_DECREMENT_DYN_STAT(x) RecIncrRawStat(http_rsb, mutex->thread_holding, (int) x, -1)
  301. #define HTTP_SUM_DYN_STAT(x, y) RecIncrRawStat(http_rsb, mutex->thread_holding, (int) x, (int64_t) y)
  302. #define HTTP_SUM_GLOBAL_DYN_STAT(x, y) RecIncrGlobalRawStatSum(http_rsb, x, y)
  303. #define HTTP_CLEAR_DYN_STAT(x) \
  304. do { \
  305. RecSetRawStatSum(http_rsb, x, 0); \
  306. RecSetRawStatCount(http_rsb, x, 0); \
  307. } while (0);
  308. #define HTTP_READ_DYN_SUM(x, S) RecGetRawStatSum(http_rsb, (int)x, &S) // This aggregates threads too
  309. #define HTTP_READ_GLOBAL_DYN_SUM(x, S) RecGetGlobalRawStatSum(http_rsb, (int)x, &S)
  310. #define HTTP_ConfigReadInteger REC_ConfigReadInteger
  311. #define HTTP_ConfigReadString REC_ConfigReadString
  312. #define HTTP_RegisterConfigUpdateFunc REC_RegisterConfigUpdateFunc
  313. /////////////////////////////////////////////////////////////
  314. //
  315. // struct HttpConfigPortRange
  316. //
  317. // configuration parameters for a range of valid SSL ports
  318. // if "low" == "high" a single port is part of this range
  319. // if "low" == "high" == -1 any port number is allowed
  320. // (corresponds to a "*" in the config file)
  321. /////////////////////////////////////////////////////////////
  322. struct HttpConfigPortRange
  323. {
  324. int low;
  325. int high;
  326. HttpConfigPortRange *next;
  327. HttpConfigPortRange()
  328. : low(0), high(0), next(0)
  329. { }
  330. ~HttpConfigPortRange()
  331. {
  332. if (next)
  333. delete next;
  334. }
  335. };
  336. /////////////////////////////////////////////////////////////
  337. // This is a little helper class, used by the HttpConfigParams
  338. // and State (txn) structure. It allows for certain configs
  339. // to be overridable per transaction more easily.
  340. struct OverridableHttpConfigParams {
  341. OverridableHttpConfigParams()
  342. : maintain_pristine_host_hdr(0), chunking_enabled(0),
  343. negative_caching_enabled(0), cache_when_to_revalidate(0),
  344. keep_alive_enabled_in(0), keep_alive_enabled_out(0), keep_alive_post_out(0),
  345. share_server_sessions(0), fwd_proxy_auth_to_parent(0),
  346. anonymize_remove_from(0), anonymize_remove_referer(0), anonymize_remove_user_agent(0),
  347. anonymize_remove_cookie(0), anonymize_remove_client_ip(0), anonymize_insert_client_ip(1),
  348. proxy_response_server_enabled(0), insert_squid_x_forwarded_for(0),
  349. send_http11_requests(3), // SEND_HTTP11_IF_REQUEST_11_AND_HOSTDB
  350. cache_http(0), cache_ignore_client_no_cache(0), cache_ignore_client_cc_max_age(1),
  351. cache_ims_on_client_no_cache(0), cache_ignore_server_no_cache(0), cache_responses_to_cookies(0),
  352. cache_ignore_auth(0), cache_urls_that_look_dynamic(0), cache_required_headers(0), // CACHE_REQUIRED_HEADERS_NONE
  353. insert_request_via_string(0), insert_response_via_string(0), doc_in_cache_skip_dns(1),
  354. negative_caching_lifetime(0),
  355. sock_recv_buffer_size_out(0), sock_send_buffer_size_out(0), sock_option_flag_out(0),
  356. sock_packet_mark_out(0), sock_packet_tos_out(0),
  357. server_tcp_init_cwnd(0),
  358. cache_heuristic_min_lifetime(0), cache_heuristic_max_lifetime(0),
  359. cache_guaranteed_min_lifetime(0), cache_guaranteed_max_lifetime(0), cache_max_stale_age(0),
  360. keep_alive_no_activity_timeout_in(0),
  361. keep_alive_no_activity_timeout_out(0),
  362. transaction_no_activity_timeout_in(0), transaction_no_activity_timeout_out(0),
  363. transaction_active_timeout_out(0),
  364. origin_max_connections(0),
  365. connect_attempts_max_retries(0), connect_attempts_max_retries_dead_server(0),
  366. connect_attempts_rr_retries(0), connect_attempts_timeout(0),
  367. post_connect_attempts_timeout(0),
  368. down_server_timeout(0), client_abort_threshold(0),
  369. freshness_fuzz_time(0), freshness_fuzz_min_time(0),
  370. max_cache_open_read_retries(0), cache_open_read_retry_time(0),
  371. // Strings / floats must come last
  372. proxy_response_server_string(NULL), proxy_response_server_string_len(0),
  373. cache_heuristic_lm_factor(0.0), freshness_fuzz_prob(0.0)
  374. { }
  375. // A few rules here:
  376. // 1. Place all MgmtByte configs before all other configs
  377. // 1. all MgmtInt/Byte configs should come before string / float configs.
  378. // The first three configs used to be @-parameters in remap.config
  379. MgmtByte maintain_pristine_host_hdr;
  380. MgmtByte chunking_enabled;
  381. ////////////////////////////////
  382. // Negative Response Caching //
  383. ////////////////////////////////
  384. MgmtByte negative_caching_enabled;
  385. MgmtByte cache_when_to_revalidate;
  386. MgmtByte keep_alive_enabled_in;
  387. MgmtByte keep_alive_enabled_out;
  388. MgmtByte keep_alive_post_out; // share server sessions for post
  389. MgmtByte share_server_sessions;
  390. MgmtByte fwd_proxy_auth_to_parent;
  391. ///////////////////////////////////////////////////////////////////
  392. // Privacy: fields which are removed from the user agent request //
  393. ///////////////////////////////////////////////////////////////////
  394. MgmtByte anonymize_remove_from;
  395. MgmtByte anonymize_remove_referer;
  396. MgmtByte anonymize_remove_user_agent;
  397. MgmtByte anonymize_remove_cookie;
  398. MgmtByte anonymize_remove_client_ip;
  399. MgmtByte anonymize_insert_client_ip;
  400. MgmtByte proxy_response_server_enabled;
  401. /////////////////////
  402. // X-Forwarded-For //
  403. /////////////////////
  404. MgmtByte insert_squid_x_forwarded_for;
  405. //////////////////////
  406. // Version Hell //
  407. //////////////////////
  408. MgmtByte send_http11_requests;
  409. ///////////////////
  410. // cache control //
  411. ///////////////////
  412. MgmtByte cache_http;
  413. MgmtByte cache_ignore_client_no_cache;
  414. MgmtByte cache_ignore_client_cc_max_age;
  415. MgmtByte cache_ims_on_client_no_cache;
  416. MgmtByte cache_ignore_server_no_cache;
  417. MgmtByte cache_responses_to_cookies;
  418. MgmtByte cache_ignore_auth;
  419. MgmtByte cache_urls_that_look_dynamic;
  420. MgmtByte cache_required_headers;
  421. MgmtByte insert_request_via_string;
  422. MgmtByte insert_response_via_string;
  423. //////////////////////
  424. // DOC IN CACHE NO DNS//
  425. //////////////////////
  426. MgmtByte doc_in_cache_skip_dns;
  427. MgmtInt negative_caching_lifetime;
  428. ///////////////////////////////////////
  429. // origin server connection settings //
  430. ///////////////////////////////////////
  431. MgmtInt sock_recv_buffer_size_out;
  432. MgmtInt sock_send_buffer_size_out;
  433. MgmtInt sock_option_flag_out;
  434. MgmtInt sock_packet_mark_out;
  435. MgmtInt sock_packet_tos_out;
  436. ///////////////////////////////
  437. // Initial congestion window //
  438. ///////////////////////////////
  439. MgmtInt server_tcp_init_cwnd;
  440. /////////////////////
  441. // cache variables //
  442. /////////////////////
  443. MgmtInt cache_heuristic_min_lifetime;
  444. MgmtInt cache_heuristic_max_lifetime;
  445. MgmtInt cache_guaranteed_min_lifetime;
  446. MgmtInt cache_guaranteed_max_lifetime;
  447. MgmtInt cache_max_stale_age;
  448. ///////////////////////////////////////////////////
  449. // connection variables. timeouts are in seconds //
  450. ///////////////////////////////////////////////////
  451. MgmtInt keep_alive_no_activity_timeout_in;
  452. MgmtInt keep_alive_no_activity_timeout_out;
  453. MgmtInt transaction_no_activity_timeout_in;
  454. MgmtInt transaction_no_activity_timeout_out;
  455. MgmtInt transaction_active_timeout_out;
  456. MgmtInt origin_max_connections;
  457. ////////////////////////////////////
  458. // origin server connect attempts //
  459. ////////////////////////////////////
  460. MgmtInt connect_attempts_max_retries;
  461. MgmtInt connect_attempts_max_retries_dead_server;
  462. MgmtInt connect_attempts_rr_retries;
  463. MgmtInt connect_attempts_timeout;
  464. MgmtInt post_connect_attempts_timeout;
  465. ////////////////////////
  466. // Negative Caching //
  467. ////////////////////////
  468. MgmtInt down_server_timeout;
  469. MgmtInt client_abort_threshold;
  470. MgmtInt freshness_fuzz_time;
  471. MgmtInt freshness_fuzz_min_time;
  472. // open read failure retries.
  473. MgmtInt max_cache_open_read_retries;
  474. MgmtInt cache_open_read_retry_time; // time is in mseconds
  475. // IMPORTANT: Here comes all strings / floats configs.
  476. ///////////////////////////////////////////////////////////////////
  477. // Server header //
  478. ///////////////////////////////////////////////////////////////////
  479. char *proxy_response_server_string; // This does not get free'd by us!
  480. size_t proxy_response_server_string_len; // Updated when server_string is set.
  481. float cache_heuristic_lm_factor;
  482. float freshness_fuzz_prob;
  483. };
  484. /////////////////////////////////////////////////////////////
  485. //
  486. // struct HttpConfigParams
  487. //
  488. // configuration parameters as they apear in the global
  489. // configuration file.
  490. /////////////////////////////////////////////////////////////
  491. struct HttpConfigParams:public ConfigInfo
  492. {
  493. public:
  494. HttpConfigParams();
  495. ~HttpConfigParams();
  496. enum
  497. {
  498. CACHE_REQUIRED_HEADERS_NONE = 0,
  499. CACHE_REQUIRED_HEADERS_AT_LEAST_LAST_MODIFIED = 1,
  500. CACHE_REQUIRED_HEADERS_CACHE_CONTROL = 2
  501. };
  502. enum
  503. {
  504. SEND_HTTP11_NEVER = 0,
  505. SEND_HTTP11_ALWAYS = 1,
  506. SEND_HTTP11_UPGRADE_HOSTDB = 2,
  507. SEND_HTTP11_IF_REQUEST_11_AND_HOSTDB = 3
  508. };
  509. public:
  510. char *proxy_hostname;
  511. int proxy_hostname_len;
  512. IpAddr inbound_ip4, inbound_ip6;
  513. IpAddr outbound_ip4, outbound_ip6;
  514. MgmtInt server_max_connections;
  515. MgmtInt origin_min_keep_alive_connections; // TODO: This one really ought to be overridable, but difficult right now.
  516. MgmtByte parent_proxy_routing_enable;
  517. MgmtByte disable_ssl_parenting;
  518. MgmtByte enable_url_expandomatic;
  519. MgmtByte no_dns_forward_to_parent;
  520. MgmtByte uncacheable_requests_bypass_parent;
  521. MgmtByte no_origin_server_dns;
  522. MgmtByte use_client_target_addr;
  523. MgmtByte use_client_source_port;
  524. char *proxy_request_via_string;
  525. int proxy_request_via_string_len;
  526. char *proxy_response_via_string;
  527. int proxy_response_via_string_len;
  528. //////////////////
  529. // WUTS headers //
  530. //////////////////
  531. MgmtByte wuts_enabled;
  532. MgmtByte log_spider_codes;
  533. ///////////////////////////////////
  534. // URL expansions for DNS lookup //
  535. ///////////////////////////////////
  536. char *url_expansions_string;
  537. char **url_expansions;
  538. int num_url_expansions;
  539. ///////////////////////////////////////////////////
  540. // connection variables. timeouts are in seconds //
  541. ///////////////////////////////////////////////////
  542. MgmtInt proxy_server_port;
  543. char *proxy_server_other_ports;
  544. MgmtByte session_auth_cache_keep_alive_enabled;
  545. MgmtInt origin_server_pipeline;
  546. MgmtInt user_agent_pipeline;
  547. MgmtInt transaction_active_timeout_in;
  548. MgmtInt accept_no_activity_timeout;
  549. MgmtInt background_fill_active_timeout;
  550. MgmtFloat background_fill_threshold;
  551. ////////////////////////////////////
  552. // origin server connect attempts //
  553. ////////////////////////////////////
  554. MgmtInt parent_connect_attempts;
  555. MgmtInt per_parent_connect_attempts;
  556. MgmtInt parent_connect_timeout;
  557. ///////////////////////////////////////////////////////////////////
  558. // Privacy: fields which are removed from the user agent request //
  559. ///////////////////////////////////////////////////////////////////
  560. char *anonymize_other_header_list;
  561. ///////////////////////////////////////////////////////////////////
  562. // Global User Agent //
  563. ///////////////////////////////////////////////////////////////////
  564. char *global_user_agent_header;
  565. size_t global_user_agent_header_size;
  566. /////////////////////
  567. // Benchmark hacks //
  568. /////////////////////
  569. MgmtByte insert_age_in_response;
  570. MgmtByte avoid_content_spoofing;
  571. MgmtByte enable_http_stats;
  572. ///////////////////
  573. // ICP variables //
  574. ///////////////////
  575. MgmtByte icp_enabled;
  576. MgmtByte stale_icp_enabled;
  577. char *cache_vary_default_text;
  578. char *cache_vary_default_images;
  579. char *cache_vary_default_other;
  580. // open write failure retries.
  581. MgmtInt max_cache_open_write_retries;
  582. ///////////////////
  583. // cache control //
  584. ///////////////////
  585. MgmtByte cache_enable_default_vary_headers;
  586. MgmtByte cache_when_to_add_no_cache_to_msie_requests;
  587. MgmtByte cache_range_lookup;
  588. ////////////////////////////////////////////
  589. // CONNECT ports (used to be == ssl_ports //
  590. ////////////////////////////////////////////
  591. char *connect_ports_string;
  592. HttpConfigPortRange *connect_ports;
  593. ///////////////
  594. // Hdr Limit //
  595. ///////////////
  596. MgmtInt request_hdr_max_size;
  597. MgmtInt response_hdr_max_size;
  598. //////////
  599. // Push //
  600. //////////
  601. MgmtByte push_method_enabled;
  602. ////////////////////////////
  603. // HTTP Referer filtering //
  604. ////////////////////////////
  605. MgmtByte referer_filter_enabled;
  606. MgmtByte referer_format_redirect;
  607. ////////////////////////////////////////////////////////
  608. // HTTP Accept-Encoding filtering based on User-Agent //
  609. ////////////////////////////////////////////////////////
  610. MgmtByte accept_encoding_filter_enabled;
  611. //////////////////
  612. // Transparency //
  613. //////////////////
  614. /// Accept connections on foreign addresses.
  615. bool client_transparency_enabled;
  616. /// Use client address to connect to origin server.
  617. bool server_transparency_enabled;
  618. ///////////////////
  619. // reverse proxy //
  620. ///////////////////
  621. MgmtByte reverse_proxy_enabled;
  622. MgmtByte url_remap_required;
  623. char *reverse_proxy_no_host_redirect;
  624. int reverse_proxy_no_host_redirect_len;
  625. ////////////////////////////
  626. // Negative Revalidating //
  627. ////////////////////////////
  628. MgmtByte negative_revalidating_enabled;
  629. MgmtInt negative_revalidating_lifetime;
  630. ///////////////////
  631. // cop access //
  632. ///////////////////
  633. MgmtByte record_cop_page;
  634. ////////////////////////
  635. // record tcp_mem_hit //
  636. ////////////////////////
  637. MgmtByte record_tcp_mem_hit;
  638. /////////////////////
  639. // Error Reporting //
  640. /////////////////////
  641. MgmtByte errors_log_error_pages;
  642. MgmtInt slow_log_threshold;
  643. MgmtInt default_buffer_size_index;
  644. MgmtInt default_buffer_water_mark;
  645. MgmtByte enable_http_info;
  646. // Cluster time delta is not a config variable,
  647. // rather it is the time skew which the manager observes
  648. int32_t cluster_time_delta;
  649. MgmtInt srv_enabled; /* added by: ebalsa */
  650. //##############################################################################
  651. //#
  652. //# Redirection
  653. //#
  654. //# 1. redirection_enabled: if set to 1, redirection is enabled.
  655. //# 2. number_of_redirectionse: The maximum number of redirections YTS permits
  656. //# 3. post_copy_size: The maximum POST data size YTS permits to copy
  657. //#
  658. //##############################################################################
  659. MgmtByte redirection_enabled;
  660. MgmtInt number_of_redirections;
  661. MgmtInt post_copy_size;
  662. //////////////////////////////////////////////////////////////////
  663. // Allow special handling of Accept* headers to be disabled to //
  664. // avoid unnecessary creation of alternates //
  665. //////////////////////////////////////////////////////////////////
  666. MgmtByte ignore_accept_mismatch;
  667. MgmtByte ignore_accept_language_mismatch;
  668. MgmtByte ignore_accept_encoding_mismatch;
  669. MgmtByte ignore_accept_charset_mismatch;
  670. ////////////////////////////////
  671. // Optimize gzip alternates //
  672. ////////////////////////////////
  673. MgmtByte normalize_ae_gzip;
  674. OverridableHttpConfigParams oride;
  675. private:
  676. /////////////////////////////////////
  677. // operator = and copy constructor //
  678. /////////////////////////////////////
  679. HttpConfigParams(const HttpConfigParams &);
  680. HttpConfigParams & operator =(const HttpConfigParams &);
  681. };
  682. /////////////////////////////////////////////////////////////
  683. //
  684. // class HttpUserAgent_RegxEntry
  685. //
  686. // configuration entry for specific User-Agent
  687. // Created at startup time only and never changed
  688. // The main purpose of the User-Agent filtering is to find "bad" user agents
  689. // and modify Accept-Encoding to prevent compression for such "bad" guys
  690. /////////////////////////////////////////////////////////////
  691. class HttpUserAgent_RegxEntry
  692. {
  693. public:
  694. typedef enum
  695. { // for more details, please see comments in "ae_ua.config" file
  696. STRTYPE_UNKNOWN = 0,
  697. STRTYPE_SUBSTR_CASE, /* .substring, .string */
  698. STRTYPE_SUBSTR_NCASE, /* .substring_ncase, .string_ncase */
  699. STRTYPE_REGEXP /* .regexp POSIX regular expression */
  700. } StrType;
  701. HttpUserAgent_RegxEntry *next;
  702. int user_agent_str_size;
  703. char *user_agent_str;
  704. bool regx_valid;
  705. StrType stype;
  706. pcre* regx;
  707. HttpUserAgent_RegxEntry();
  708. ~HttpUserAgent_RegxEntry();
  709. bool create(char *refexp_str = NULL, char *errmsgbuf = NULL, int errmsgbuf_size = 0);
  710. };
  711. /////////////////////////////////////////////////////////////
  712. //
  713. // class HttpConfig
  714. //
  715. /////////////////////////////////////////////////////////////
  716. class HttpConfig
  717. {
  718. public:
  719. static int init_aeua_filter(char *config_fname);
  720. static void startup();
  721. static void reconfigure();
  722. inkcoreapi static HttpConfigParams *acquire();
  723. inkcoreapi static void release(HttpConfigParams * params);
  724. // dump
  725. static void dump_config();
  726. // parse ssl ports configuration string
  727. static HttpConfigPortRange *parse_ports_list(char *ports_str);
  728. // parse DNS URL expansions string
  729. static char **parse_url_expansions(char *url_expansions_str, int *num_expansions);
  730. static void *cluster_delta_cb(void *opaque_token, char *data_raw, int data_len);
  731. public:
  732. static int m_id;
  733. static HttpConfigParams m_master;
  734. static HttpUserAgent_RegxEntry *user_agent_list;
  735. };
  736. // DI's request to disable ICP on the fly
  737. extern volatile int32_t icp_dynamic_enabled;
  738. /////////////////////////////////////////////////////////////
  739. /////////////////////////////////////////////////////////////
  740. //
  741. // inline functions
  742. //
  743. /////////////////////////////////////////////////////////////
  744. /////////////////////////////////////////////////////////////
  745. inline
  746. HttpConfigParams::HttpConfigParams()
  747. : proxy_hostname(0),
  748. proxy_hostname_len(0),
  749. server_max_connections(0),
  750. origin_min_keep_alive_connections(0),
  751. parent_proxy_routing_enable(0),
  752. disable_ssl_parenting(0),
  753. enable_url_expandomatic(0),
  754. no_dns_forward_to_parent(0),
  755. uncacheable_requests_bypass_parent(1),
  756. no_origin_server_dns(0),
  757. use_client_target_addr(0),
  758. use_client_source_port(0),
  759. proxy_request_via_string(0),
  760. proxy_request_via_string_len(0),
  761. proxy_response_via_string(0),
  762. proxy_response_via_string_len(0),
  763. wuts_enabled(0),
  764. log_spider_codes(0),
  765. url_expansions_string(0),
  766. url_expansions(0),
  767. num_url_expansions(0),
  768. proxy_server_port(0),
  769. proxy_server_other_ports(0),
  770. session_auth_cache_keep_alive_enabled(0),
  771. origin_server_pipeline(0),
  772. user_agent_pipeline(0),
  773. transaction_active_timeout_in(0),
  774. accept_no_activity_timeout(0),
  775. background_fill_active_timeout(0),
  776. background_fill_threshold(0.0),
  777. parent_connect_attempts(0),
  778. per_parent_connect_attempts(0),
  779. parent_connect_timeout(0),
  780. anonymize_other_header_list(NULL),
  781. global_user_agent_header(NULL),
  782. global_user_agent_header_size(0),
  783. insert_age_in_response(1),
  784. avoid_content_spoofing(1),
  785. enable_http_stats(1),
  786. icp_enabled(0),
  787. stale_icp_enabled(0),
  788. cache_vary_default_text(0),
  789. cache_vary_default_images(0),
  790. cache_vary_default_other(0),
  791. max_cache_open_write_retries(0),
  792. cache_enable_default_vary_headers(0),
  793. cache_when_to_add_no_cache_to_msie_requests(0),
  794. connect_ports_string(0),
  795. connect_ports(0),
  796. request_hdr_max_size(0),
  797. response_hdr_max_size(0),
  798. push_method_enabled(0),
  799. referer_filter_enabled(0),
  800. referer_format_redirect(0),
  801. accept_encoding_filter_enabled(0),
  802. client_transparency_enabled(0),
  803. server_transparency_enabled(0),
  804. reverse_proxy_enabled(0),
  805. url_remap_required(0),
  806. negative_revalidating_enabled(0),
  807. negative_revalidating_lifetime(0),
  808. record_cop_page(0),
  809. record_tcp_mem_hit(0),
  810. errors_log_error_pages(0),
  811. default_buffer_size_index(0),
  812. default_buffer_water_mark(0),
  813. enable_http_info(0),
  814. cluster_time_delta(0),
  815. srv_enabled(0),
  816. redirection_enabled(1),
  817. number_of_redirections(0),
  818. post_copy_size(2048),
  819. ignore_accept_mismatch(0),
  820. ignore_accept_language_mismatch(0),
  821. ignore_accept_encoding_mismatch(0),
  822. ignore_accept_charset_mismatch(0),
  823. normalize_ae_gzip(1)
  824. {
  825. }
  826. inline
  827. HttpConfigParams::~HttpConfigParams()
  828. {
  829. ats_free(proxy_hostname);
  830. ats_free(proxy_request_via_string);
  831. ats_free(proxy_response_via_string);
  832. ats_free(url_expansions_string);
  833. ats_free(proxy_server_other_ports);
  834. ats_free(anonymize_other_header_list);
  835. ats_free(global_user_agent_header);
  836. ats_free(oride.proxy_response_server_string);
  837. ats_free(cache_vary_default_text);
  838. ats_free(cache_vary_default_images);
  839. ats_free(cache_vary_default_other);
  840. ats_free(connect_ports_string);
  841. ats_free(reverse_proxy_no_host_redirect);
  842. ats_free(url_expansions);
  843. if (connect_ports) {
  844. delete connect_ports;
  845. }
  846. }
  847. #endif /* #ifndef _HttpConfig_h_ */