📄 mod_jk.c
字号:
* * JkSESSIONIndicator SSL_SESSION_ID */static const char *jk_set_session_indicator(cmd_parms * cmd, void *dummy, const char *indicator){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); conf->session_indicator = apr_pstrdup(cmd->pool, indicator); return NULL;}/* * JkKEYSIZEIndicator Directive Handling * * JkKEYSIZEIndicator SSL_CIPHER_USEKEYSIZE */static const char *jk_set_key_size_indicator(cmd_parms * cmd, void *dummy, const char *indicator){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); conf->key_size_indicator = apr_pstrdup(cmd->pool, indicator); return NULL;}/* * JkOptions Directive Handling * * * +ForwardSSLKeySize => Forward SSL Key Size, to follow 2.3 specs but may broke old TC 3.2 * -ForwardSSLKeySize => Don't Forward SSL Key Size, will make mod_jk works with all TC release * ForwardURICompat => Forward URI normally, less spec compliant but mod_rewrite compatible (old TC) * ForwardURICompatUnparsed => Forward URI as unparsed, spec compliant but broke mod_rewrite (old TC) * ForwardURIEscaped => Forward URI escaped and Tomcat (3.3 rc2) stuff will do the decoding part * ForwardDirectories => Forward all directory requests with no index files to Tomcat * +ForwardSSLCertChain => Forward SSL Cert Chain * -ForwardSSLCertChain => Don't Forward SSL Cert Chain (default) */static const char *jk_set_options(cmd_parms * cmd, void *dummy, const char *line){ int opt = 0; int mask = 0; char action; char *w; server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); while (line[0] != 0) { w = ap_getword_conf(cmd->pool, &line); action = 0; if (*w == '+' || *w == '-') { action = *(w++); } mask = 0; if (action == '-' && !strncasecmp(w, "ForwardURI", strlen("ForwardURI"))) return apr_pstrcat(cmd->pool, "JkOptions: Illegal option '-", w, "': ForwardURI* options can not be disabled", NULL); if (!strcasecmp(w, "ForwardURICompat")) { opt = JK_OPT_FWDURICOMPAT; mask = JK_OPT_FWDURIMASK; } else if (!strcasecmp(w, "ForwardURICompatUnparsed")) { opt = JK_OPT_FWDURICOMPATUNPARSED; mask = JK_OPT_FWDURIMASK; } else if (!strcasecmp(w, "ForwardURIEscaped")) { opt = JK_OPT_FWDURIESCAPED; mask = JK_OPT_FWDURIMASK; } else if (!strcasecmp(w, "ForwardURIProxy")) { opt = JK_OPT_FWDURIPROXY; mask = JK_OPT_FWDURIMASK; } else if (!strcasecmp(w, "ForwardDirectories")) { opt = JK_OPT_FWDDIRS; } else if (!strcasecmp(w, "ForwardLocalAddress")) { opt = JK_OPT_FWDLOCAL; } else if (!strcasecmp(w, "FlushPackets")) { opt = JK_OPT_FLUSHPACKETS; } else if (!strcasecmp(w, "FlushHeader")) { opt = JK_OPT_FLUSHEADER; } else if (!strcasecmp(w, "DisableReuse")) { opt = JK_OPT_DISABLEREUSE; } else if (!strcasecmp(w, "ForwardSSLCertChain")) { opt = JK_OPT_FWDCERTCHAIN; } else if (!strcasecmp(w, "ForwardKeySize")) { opt = JK_OPT_FWDKEYSIZE; } else if (!strcasecmp(w, "RejectUnsafeURI")) { opt = JK_OPT_REJECTUNSAFE; } else return apr_pstrcat(cmd->pool, "JkOptions: Illegal option '", w, "'", NULL); conf->options &= ~mask; if (action == '-') { conf->exclude_options |= opt; } else if (action == '+') { conf->options |= opt; } else { /* for now +Opt == Opt */ conf->options |= opt; } } return NULL;}/* * JkEnvVar Directive Handling * * JkEnvVar MYOWNDIR */static const char *jk_add_env_var(cmd_parms * cmd, void *dummy, const char *env_name, const char *default_value){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); conf->envvars_in_use = JK_TRUE; /* env_name is mandatory, default_value is optional. * No value means send the attribute only, if the env var is set during runtime. */ apr_table_setn(conf->envvars, env_name, default_value ? default_value : ""); apr_table_setn(conf->envvars_def, env_name, default_value ? "1" : "0"); return NULL;}/* * JkWorkerProperty Directive Handling * * JkWorkerProperty name=value */static const char *jk_set_worker_property(cmd_parms * cmd, void *dummy, const char *line){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); const char *err_string = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err_string != NULL) { return err_string; } if (jk_map_read_property(conf->worker_properties, line, JK_MAP_HANDLE_DUPLICATES, conf->log) == JK_FALSE) return apr_pstrcat(cmd->temp_pool, "Invalid JkWorkerProperty ", line, NULL); return NULL;}static const command_rec jk_cmds[] = { /* * JkWorkersFile specifies a full path to the location of the worker * properties file. * * This file defines the different workers used by apache to redirect * servlet requests. */ AP_INIT_TAKE1("JkWorkersFile", jk_set_worker_file, NULL, RSRC_CONF, "the name of a worker file for the Tomcat servlet containers"), /* * JkMountFile specifies a full path to the location of the * uriworker properties file. * * This file defines the different mapping for workers used by apache * to redirect servlet requests. */ AP_INIT_TAKE1("JkMountFile", jk_set_mount_file, NULL, RSRC_CONF, "the name of a mount file for the Tomcat servlet uri mapping"), /* * JkMountFileReload specifies the reload check interval for the * uriworker properties file. * * Default value is: JK_URIMAP_DEF_RELOAD */ AP_INIT_TAKE1("JkMountFileReload", jk_set_mount_file_reload, NULL, RSRC_CONF, "the reload check interval of the mount file"), /* * JkAutoMount specifies that the list of handled URLs must be * asked to the servlet engine (autoconf feature) */ AP_INIT_TAKE12("JkAutoMount", jk_automount_context, NULL, RSRC_CONF, "automatic mount points to a Tomcat worker"), /* * JkMount mounts a url prefix to a worker (the worker need to be * defined in the worker properties file. */ AP_INIT_TAKE12("JkMount", jk_mount_context, NULL, RSRC_CONF|ACCESS_CONF, "A mount point from a context to a Tomcat worker"), /* * JkUnMount unmounts a url prefix to a worker (the worker need to be * defined in the worker properties file. */ AP_INIT_TAKE12("JkUnMount", jk_unmount_context, NULL, RSRC_CONF|ACCESS_CONF, "A no mount point from a context to a Tomcat worker"), /* * JkMountCopy specifies if mod_jk should copy the mount points * from the main server to the virtual servers. */ AP_INIT_FLAG("JkMountCopy", jk_set_mountcopy, NULL, RSRC_CONF, "Should the base server mounts be copied to the virtual server"), /* * JkStripSession specifies if mod_jk should strip the ;jsessionid * from the unmapped urls */ AP_INIT_FLAG("JkStripSession", jk_set_strip_session, NULL, RSRC_CONF, "Should the server strip the jsessionid from unmapped URLs"), /* * JkLogFile & JkLogLevel specifies to where should the plugin log * its information and how much. * JkLogStampFormat specify the time-stamp to be used on log */ AP_INIT_TAKE1("JkLogFile", jk_set_log_file, NULL, RSRC_CONF, "Full path to the Tomcat module log file"), AP_INIT_TAKE1("JkShmFile", jk_set_shm_file, NULL, RSRC_CONF, "Full path to the Tomcat module shared memory file"), AP_INIT_TAKE1("JkShmSize", jk_set_shm_size, NULL, RSRC_CONF, "Size of the shared memory file in KBytes"), AP_INIT_TAKE1("JkLogLevel", jk_set_log_level, NULL, RSRC_CONF, "The Tomcat module log level, can be debug, " "info, error or emerg"), AP_INIT_TAKE1("JkLogStampFormat", jk_set_log_fmt, NULL, RSRC_CONF, "The Tomcat module log format, follow strftime syntax"), AP_INIT_TAKE1("JkRequestLogFormat", jk_set_request_log_format, NULL, RSRC_CONF, "The mod_jk module request log format string"), /* * Automatically Alias webapp context directories into the Apache * document space. */ AP_INIT_TAKE1("JkAutoAlias", jk_set_auto_alias, NULL, RSRC_CONF, "The mod_jk module automatic context apache alias directory"), /* * Enable worker name to be set in an environment variable. * this way one can use LocationMatch together with mod_end, * mod_setenvif and mod_rewrite to set the target worker. * Use this in combination with SetHandler jakarta-servlet to * make mod_jk the handler for the request. * */ AP_INIT_TAKE1("JkWorkerIndicator", jk_set_worker_indicator, NULL, RSRC_CONF, "Name of the Apache environment that contains the worker name"), /* * Apache has multiple SSL modules (for example apache_ssl, stronghold * IHS ...). Each of these can have a different SSL environment names * The following properties let the administrator specify the envoiroment * variables names. * * HTTPS - indication for SSL * CERTS - Base64-Der-encoded client certificates. * CIPHER - A string specifing the ciphers suite in use. * KEYSIZE - Size of Key used in dialogue (#bits are secure) * SESSION - A string specifing the current SSL session. */ AP_INIT_TAKE1("JkHTTPSIndicator", jk_set_https_indicator, NULL, RSRC_CONF, "Name of the Apache environment that contains SSL indication"), AP_INIT_TAKE1("JkCERTSIndicator", jk_set_certs_indicator, NULL, RSRC_CONF, "Name of the Apache environment that contains SSL client certificates"), AP_INIT_TAKE1("JkCIPHERIndicator", jk_set_cipher_indicator, NULL, RSRC_CONF, "Name of the Apache environment that contains SSL client cipher"), AP_INIT_TAKE1("JkSESSIONIndicator", jk_set_session_indicator, NULL, RSRC_CONF, "Name of the Apache environment that contains SSL session"), AP_INIT_TAKE1("JkKEYSIZEIndicator", jk_set_key_size_indicator, NULL, RSRC_CONF, "Name of the Apache environment that contains SSL key size in use"), AP_INIT_TAKE1("JkCERTCHAINPrefix", jk_set_certchain_prefix, NULL, RSRC_CONF, "Name of the Apache environment (prefix) that contains SSL client chain certificates"), AP_INIT_FLAG("JkExtractSSL", jk_set_enable_ssl, NULL, RSRC_CONF, "Turns on SSL processing and information gathering by mod_jk"), /* * Options to tune mod_jk configuration * for now we understand : * +ForwardSSLKeySize => Forward SSL Key Size, to follow 2.3 specs but may broke old TC 3.2 * -ForwardSSLKeySize => Don't Forward SSL Key Size, will make mod_jk works with all TC release * ForwardURICompat => Forward URI normally, less spec compliant but mod_rewrite compatible (old TC) * ForwardURICompatUnparsed => Forward URI as unparsed, spec compliant but broke mod_rewrite (old TC) * ForwardURIEscaped => Forward URI escaped and Tomcat (3.3 rc2) stuff will do the decoding part * +ForwardSSLCertChain => Forward SSL certificate chain * -ForwardSSLCertChain => Don't forward SSL certificate chain */ AP_INIT_RAW_ARGS("JkOptions", jk_set_options, NULL, RSRC_CONF, "Set one of more options to configure the mod_jk module"), /* * JkEnvVar let user defines envs var passed from WebServer to * Servlet Engine */ AP_INIT_TAKE12("JkEnvVar", jk_add_env_var, NULL, RSRC_CONF, "Adds a name of environment variable and an optional value " "that should be sent to servlet-engine"), AP_INIT_RAW_ARGS("JkWorkerProperty", jk_set_worker_property, NULL, RSRC_CONF, "Set workers.properties formated directive"), {NULL}};/* ========================================================================= *//* The JK module handlers *//* ========================================================================= *//** Util - cleanup shmem. */static apr_status_t jk_cleanup_shmem(void *data){ jk_shm_close(); return APR_SUCCESS;}/** Main service method, called to forward a request to tomcat */static int jk_handler(request_rec * r){ const char *worker_name; jk_server_conf_t *xconf; int rc, dmt = 1; /* We do DIR_MAGIC_TYPE here to make sure TC gets all requests, even * if they are directory requests, in case there are no static files * visible to Apache and/or DirectoryIndex was not used. This is only * used when JkOptions has ForwardDirectories set. */ /* Not for me, try next handler */ if (strcmp(r->handler, JK_HANDLER) && (dmt = strcmp(r->handler, DIR_MAGIC_TYPE))) return DECLINED; xconf = (jk_server_conf_t *) ap_get_module_config(r->server->module_config, &jk_module); JK_TRACE_ENTER(xconf->log); if (apr_table_get(r->subprocess_env, "no-jk")) { if (JK_IS_DEBUG_LEVEL(xconf->log)) jk_log(xconf->log, JK_LOG_DEBUG, "Into handler no-jk env var detected for uri=%s, declined", r->uri); JK_TRACE_EXIT(xconf->log); return DECLINED; } /* Was the option to forward directories to Tomcat set? */ if (!dmt && !(xconf->options & JK_OPT_FWDDIRS)) { JK_TRACE_EXIT(xconf->log); return DECLINED; } worker_name = apr_table_get(r->notes, JK_NOTE_WORKER_NAME); /* Set up r->read_chunked flags for chunked encoding, if present */ if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)) != APR_SUCCESS) { JK_TRACE_EXIT(xconf->log); return rc; } if (worker_name == NULL) { /* we may be here because of a manual directive ( that overrides translate and sets the handler directly ). We still need to know th
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -