mod_proxy.c revision 2dbd6146bf47e7eafb45bf3b79b242aa45f6f8ca
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* Licensed to the Apache Software Foundation (ASF) under one or more
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * contributor license agreements. See the NOTICE file distributed with
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * this work for additional information regarding copyright ownership.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * The ASF licenses this file to You under the Apache License, Version 2.0
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * (the "License"); you may not use this file except in compliance with
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * the License. You may obtain a copy of the License at
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Unless required by applicable law or agreed to in writing, software
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * distributed under the License is distributed on an "AS IS" BASIS,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * See the License for the specific language governing permissions and
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * limitations under the License.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAPR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *));
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAPR_DECLARE_OPTIONAL_FN(int, ssl_engine_disable, (conn_rec *));
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAPR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb#define MAX(x,y) ((x) >= (y) ? (x) : (y))
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* return the sizeof of one lb_worker in scoreboard. */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic int ap_proxy_lb_worker_size(void)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return sizeof(proxy_worker_stat);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * A Web proxy module. Stages:
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * translate_name: set filename to proxy:<URL>
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * map_to_storage: run proxy_walk (rather than directory_walk/file_walk)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * can't trust directory_walk/file_walk since these are
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * not in our filesystem. Prevents mod_http from serving
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * the TRACE request we will set aside to handle later.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * type_checker: set type to PROXY_MAGIC_TYPE if filename begins proxy:
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * fix_ups: convert the URL stored in the filename to the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * canonical form.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * handler: handle proxy requests
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* -------------------------------------------------------------- */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* Translate the URL into a 'filename' */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb (w)->recv_buffer_size_set = (c)->recv_buffer_size_set; \
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb } while (0)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *key,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *val)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Normalized load factor. Used with BalancerMamber,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * it is a number between 1 and 100.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "LoadFactor must be number between 1..100";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* If set it will give the retry timeout for the worker
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * The default value is 60 seconds, meaning that if
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * in error state, it will be retried after that timeout.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "Retry must be a positive value";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Time in seconds that will destroy all the connections
b45c1c292ff1fa635004ae81fa691f8cb3cdda85rbb * that exced the smax
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "TTL must be at least one second";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Initial number of connections to remote
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "Min must be a positive number";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Maximum number of connections to remote
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "Max must be a positive number";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* XXX: More inteligent naming needed */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* Maximum number of connections to remote that
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * will not be destroyed
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "Smax must be a positive number";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* Acquire timeout in milliseconds.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * If set this will be the maximum time to
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * wait for a free connection.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "Acquire must be at least one mili second";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* Connection timeout in seconds.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * Defaults to server timeout.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "Timeout must be at least one second";
3e392a5afd51526de3cb15d57ee46d8cb160ae65gregames worker->io_buffer_size = ((s > AP_IOBUFSIZE) ? s : AP_IOBUFSIZE);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe return "ReceiveBufferSize must be >= 512 bytes, or 0 for system default.";
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe return "KeepAlive must be On|Off";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* Worker route.
3e392a5afd51526de3cb15d57ee46d8cb160ae65gregames return "Route length must be < 64 characters";
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe /* Worker redirection route.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "Redirect length must be < 64 characters";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe const char *v;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* Worker status.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe for (v = val; *v; v++) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if (*v == '+') {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe else if (*v == '-') {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe return "Unknown status parameter option";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "flushpackets must be on|off|auto";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "flushwait must be <= 1000, or 0 for system default of 10 millseconds.";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe worker->flush_wait = ival * 1000; /* change to microseconds */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* Ping/Pong timeout in seconds.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "Ping/Pong timeout must be at least one second";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "lbset must be between 0 and 99";
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "unknown Worker parameter";
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowestatic const char *set_balancer_param(proxy_server_conf *conf,
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe const char *key,
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe const char *val)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe /* Balancer sticky session name.
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * Set to something like JSESSIONID or
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * PHPSESSIONID, etc..,
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe /* If set to 'on' the session will break
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * if the worker is in error state or
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * disabled.
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe return "failover must be On|Off";
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe /* Balancer timeout in seconds.
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * If set this will be the maximum time to
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * wait for a free worker.
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * Default is not to wait.
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe return "timeout must be at least one second";
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe /* Maximum number of failover attempts before
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * giving up.
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe return "maximum number of attempts must be a positive number";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb provider = ap_lookup_provider(PROXY_LBMETHOD, val, "0");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "unknown lbmethod";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "unknown Balancer parameter";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic int alias_match(const char *uri, const char *alias_fakename)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *end_fakename = alias_fakename + strlen(alias_fakename);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* any number of '/' in the alias matches any number in
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * the supplied URI, but there must be at least one...
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Other characters are compared literally */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* fixup badly encoded stuff (e.g. % as last character) */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* We reach the end of the uri before the end of "alias_fakename"
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * for example uri is "/" and alias_fakename "/examples"
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Check last alias path component matched all the way */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe if (aliasp[-1] != '/' && *urip != '\0' && *urip != '/')
11fb2f3611e6ff9a541e10b13e3108934f828141gregames /* Return number of characters from URI which matched (may be
11fb2f3611e6ff9a541e10b13e3108934f828141gregames * greater than length of alias, since we may have matched
11fb2f3611e6ff9a541e10b13e3108934f828141gregames * doubled slashes)
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe/* Detect if an absoluteURI should be proxied or not. Note that we
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * have to do this during this phase because later phases are
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * "short-circuiting"... i.e. translate_names will end when the first
2f1949bb0e3c209db94c8d521cba7380b9d11421trawick * module returns OK. So for example, if the request is something like:
2f1949bb0e3c209db94c8d521cba7380b9d11421trawick * mod_alias will notice the /cgi-bin part and ScriptAlias it and
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * short-circuit the proxy... just because of the ordering in the
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * configuration file.
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Ick... msvc (perhaps others) promotes ternary short results to int */
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* but it might be something vhosted */
8aefbd756763807188d2e3ce336a8680e4893066wrowe && !strcasecmp(r->parsed_uri.scheme, ap_http_scheme(r))
8aefbd756763807188d2e3ce336a8680e4893066wrowe && ap_matches_request_vhost(r, r->parsed_uri.hostname,
8aefbd756763807188d2e3ce336a8680e4893066wrowe (apr_port_t)(r->parsed_uri.port_str ? r->parsed_uri.port
8aefbd756763807188d2e3ce336a8680e4893066wrowe r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL);
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* We need special treatment for CONNECT proxying: it has no scheme part */
8aefbd756763807188d2e3ce336a8680e4893066wrowe r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL);
8aefbd756763807188d2e3ce336a8680e4893066wrowestatic const char *proxy_interpolate(request_rec *r, const char *str)
a8d11d78181478da6a672f7fbc58b8d523351f49wrowe /* Interpolate an env str in a configuration string
8aa5ca8ff2a4d8e56f62ea3d461e2799136da085trawick * Syntax ${var} --> value_of(var)
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * Method: replace one var, and recurse on remainder of string
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * Nothing clever here, and crap like nested vars may do silly things
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * but we'll at least avoid sending the unwary into a loop
a8d11d78181478da6a672f7fbc58b8d523351f49wrowe const char *start;
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe const char *end;
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe const char *var;
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe const char *val;
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe const char *firstpart;
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* OK, this is syntax we want to interpolate. Is there such a var ? */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe apr_array_header_t *ret = apr_array_make(r->pool, hdr->nelts,
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe sizeof (struct proxy_alias));
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe struct proxy_alias *old = (struct proxy_alias *) hdr->elts;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe struct proxy_alias *ent = (struct proxy_alias *) conf->aliases->elts;
a9a4544168a37b43bd180b3703ccee995f27a80awrowe proxy_dir_conf *dconf = ap_get_module_config(r->per_dir_config,
a9a4544168a37b43bd180b3703ccee995f27a80awrowe const char *fake;
a9a4544168a37b43bd180b3703ccee995f27a80awrowe const char *real;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* someone has already set up the proxy, it was possibly ourselves
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * in proxy_detect
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* XXX: since r->uri has been manipulated already we're not really
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * compliant with RFC1945 at this point. But this probably isn't
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * an issue because this is a hybrid proxy/origin server.
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe if (!ap_regexec(ent[i].regex, r->uri, AP_MAX_REG_MATCH, regm, 0)) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe found = ap_pregsub(r->pool, real, r->uri, AP_MAX_REG_MATCH,
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Note: The strcmp() below catches cases where there
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * was no regex substitution. This is so cases like:
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * ProxyPassMatch \.gif balancer://foo
59513b1275fdc2021d4949ee03ae8229469abb86wrowe * will work "as expected". The upshot is that the 2
59513b1275fdc2021d4949ee03ae8229469abb86wrowe * directives below act the exact same way (ie: $1 is implied):
59513b1275fdc2021d4949ee03ae8229469abb86wrowe * ProxyPassMatch ^(/.*\.gif)$ balancer://foo
59513b1275fdc2021d4949ee03ae8229469abb86wrowe * ProxyPassMatch ^(/.*\.gif)$ balancer://foo$1
85bb5b92490e4f095aae394118fc588a8f4c486fwrowe * which may be confusing.
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe if (len != 0) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe proxy_server_conf *sconf = ap_get_module_config(r->server->module_config,
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe ap_conf_vector_t *per_dir_defaults = r->server->lookup_defaults;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe ap_conf_vector_t **sec_proxy = (ap_conf_vector_t **) sconf->sec_proxy->elts;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* XXX: shouldn't we use URI here? Canonicalize it first?
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * Pass over "proxy:" prefix
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe for (j = 0; j < num_sec; ++j)
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe entry_proxy = ap_get_module_config(entry_config, &proxy_module);
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* XXX: What about case insensitive matching ???
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * Compare regex, fnmatch or string as appropriate
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * If the entry doesn't relate, then continue
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe per_dir_defaults = ap_merge_per_dir_configs(r->pool, per_dir_defaults,
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe if (!r->proxyreq || !r->filename || strncmp(r->filename, "proxy:", 6) != 0)
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Don't let the core or mod_http map_to_storage hooks handle this,
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * We don't need directory/file_walk, and we want to TRACE on our own.
8aefbd756763807188d2e3ce336a8680e4893066wrowe/* -------------------------------------------------------------- */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe/* Fixup the filename */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * Canonicalise the URL
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe char *url, *p;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe proxy_dir_conf *dconf = ap_get_module_config(r->per_dir_config,
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe if (!r->proxyreq || !r->filename || strncmp(r->filename, "proxy:", 6) != 0)
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* XXX: Shouldn't we try this before we run the proxy_walk? */
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((dconf->interpolate_env == 1) && (r->proxyreq == PROXYREQ_REVERSE)) {
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* create per-request copy of reverse proxy conf,
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * and interpolate vars in it
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe proxy_req_conf *rconf = apr_palloc(r->pool, sizeof(proxy_req_conf));
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe ap_set_module_config(r->request_config, &proxy_module, rconf);
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe rconf->cookie_paths = proxy_vars(r, dconf->cookie_paths);
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe rconf->cookie_domains = proxy_vars(r, dconf->cookie_domains);
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* canonicalise each specific scheme */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe if ((access_status = proxy_run_canon_handler(r, url))) {
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe return OK; /* otherwise; we've done the best we can */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe/* Send a redirection if the request contains a hostname which is not */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe/* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe/* servers like Netscape's allow this and access hosts from the local */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe/* domain in this case. I think it is better to redirect to a FQDN, since */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe/* these will later be found in the bookmarks files. */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe/* The "ProxyDomain" directive determines what domain will be appended */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowestatic int proxy_needsdomain(request_rec *r, const char *url, const char *domain)
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe const char *ref;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* We only want to worry about GETs */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe if (!r->proxyreq || r->method_number != M_GET || !r->parsed_uri.hostname)
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* If host does contain a dot already, or it is "localhost", decline */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe || strcasecmp(r->parsed_uri.hostname, "localhost") == 0)
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Reassemble the request, but insert the domain after the host name */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Note that the domain name always starts with a dot */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe r->parsed_uri.hostname = apr_pstrcat(r->pool, r->parsed_uri.hostname,
2787ef5edc27fa4f6777ba8d51aa48fd9fdf54bbwrowe/* -------------------------------------------------------------- */
2787ef5edc27fa4f6777ba8d51aa48fd9fdf54bbwrowe/* Invoke handler */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe const char *p2;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe struct proxy_remote *ents = (struct proxy_remote *) proxies->elts;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe const char *str;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe struct dirconn_entry *list = (struct dirconn_entry *)conf->dirconn->elts;
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* is this for us? */
8aefbd756763807188d2e3ce336a8680e4893066wrowe if (!r->proxyreq || !r->filename || strncmp(r->filename, "proxy:", 6) != 0)
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* handle max-forwards / OPTIONS / TRACE */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe if ((str = apr_table_get(r->headers_in, "Max-Forwards"))) {
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe switch (r->method_number) {
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe "Max-Forwards has reached zero - proxy loop?");
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* set configured max-forwards */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd : 0));
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Allow "error-notes" string to be printed by ap_send_error_response()
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * Note; this goes nowhere, canned error response need an overhaul.
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe "TRACE forbidden by server configuration");
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe "proxy: TRACE forbidden by server configuration");
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Can't test ap_should_client_block, we aren't ready to send
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * the client a 100 Continue response till the connection has
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * been established
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe && (r->read_length || r->read_chunked || r->remaining))
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Allow "error-notes" string to be printed by ap_send_error_response()
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * Note; this goes nowhere, canned error response need an overhaul.
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe "TRACE with request body is not allowed");
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe "proxy: TRACE with request body is not allowed");
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe if (p == NULL) {
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* If the host doesn't have a domain name, add one and redirect. */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Check URI's destination host against NoProxy hosts */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Bypass ProxyRemote server lookup if configured as NoProxy */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe for (direct_connect = i = 0; i < conf->dirconn->nelts &&
8aefbd756763807188d2e3ce336a8680e4893066wrowe (direct_connect) ? "NoProxy for %s" : "UseProxy for %s",
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* Try to obtain the most suitable worker */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe access_status = ap_proxy_pre_request(&worker, &balancer, r, conf, &url);
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * Only return if access_status is not HTTP_SERVICE_UNAVAILABLE
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * This gives other modules the chance to hook into the
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * request_status hook and decide what to do in this situation.
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * Ensure that balancer is NULL if worker is NULL to prevent
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * potential problems in the post_request hook.
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe if (balancer && balancer->max_attempts_set && !max_attempts)
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* firstly, try a proxy, unless a NoProxy directive is active */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe p2 = ap_strchr_c(ents[i].scheme, ':'); /* is it a partial URL? */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe (p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) ||
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* handle the scheme */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe "Trying to run scheme_handler against proxy");
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* an error or success */
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe /* we failed to talk to the upstream proxy */
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* otherwise, try it direct */
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* N.B. what if we're behind a firewall, where we must use a proxy or
8aefbd756763807188d2e3ce336a8680e4893066wrowe * give up??
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* handle the scheme */
8aefbd756763807188d2e3ce336a8680e4893066wrowe "Running scheme %s handler (attempt %d)",
8aefbd756763807188d2e3ce336a8680e4893066wrowe access_status = proxy_run_scheme_handler(r, worker, conf,
8aefbd756763807188d2e3ce336a8680e4893066wrowe else if (access_status == HTTP_INTERNAL_SERVER_ERROR) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* Unrecoverable server error.
8aefbd756763807188d2e3ce336a8680e4893066wrowe * We can not failover to another worker.
8aefbd756763807188d2e3ce336a8680e4893066wrowe * Mark the worker as unusable if member of load balancer
0540a0b469147b52e858587270dba31c2aaa9e09wrowe /* Recoverable server error.
0540a0b469147b52e858587270dba31c2aaa9e09wrowe * We can failover to another worker
a9a4544168a37b43bd180b3703ccee995f27a80awrowe * Mark the worker as unusable if member of load balancer
0540a0b469147b52e858587270dba31c2aaa9e09wrowe /* Unrecoverable error.
0540a0b469147b52e858587270dba31c2aaa9e09wrowe * Return the origin status code to the client.
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* Try again if the worker is unusable and the service is
8aefbd756763807188d2e3ce336a8680e4893066wrowe * unavailable.
0540a0b469147b52e858587270dba31c2aaa9e09wrowe "proxy: No protocol handler was valid for the URL %s. "
0540a0b469147b52e858587270dba31c2aaa9e09wrowe "If you are using a DSO version of mod_proxy, make sure "
948096a99010fccf648814fecf38f75c689172d7wrowe "the proxy submodules are included in the configuration "
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe int post_status = proxy_run_post_request(worker, balancer, r, conf);
0540a0b469147b52e858587270dba31c2aaa9e09wrowe post_status = OK; /* no post_request handler available */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* TODO: recycle direct worker */
948096a99010fccf648814fecf38f75c689172d7wrowe/* -------------------------------------------------------------- */
948096a99010fccf648814fecf38f75c689172d7wrowe/* Setup configurable data */
948096a99010fccf648814fecf38f75c689172d7wrowestatic void * create_proxy_config(apr_pool_t *p, server_rec *s)
948096a99010fccf648814fecf38f75c689172d7wrowe proxy_server_conf *ps = apr_pcalloc(p, sizeof(proxy_server_conf));
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->sec_proxy = apr_array_make(p, 10, sizeof(ap_conf_vector_t *));
948096a99010fccf648814fecf38f75c689172d7wrowe ps->proxies = apr_array_make(p, 10, sizeof(struct proxy_remote));
948096a99010fccf648814fecf38f75c689172d7wrowe ps->aliases = apr_array_make(p, 10, sizeof(struct proxy_alias));
948096a99010fccf648814fecf38f75c689172d7wrowe ps->noproxies = apr_array_make(p, 10, sizeof(struct noproxy_entry));
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ps->dirconn = apr_array_make(p, 10, sizeof(struct dirconn_entry));
0540a0b469147b52e858587270dba31c2aaa9e09wrowe ps->allowed_connect_ports = apr_array_make(p, 10, sizeof(int));
948096a99010fccf648814fecf38f75c689172d7wrowe ps->workers = apr_array_make(p, 10, sizeof(proxy_worker));
948096a99010fccf648814fecf38f75c689172d7wrowe ps->balancers = apr_array_make(p, 10, sizeof(proxy_balancer));
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */
a9a4544168a37b43bd180b3703ccee995f27a80awrowe ps->recv_buffer_size = 0; /* this default was left unset for some reason */
948096a99010fccf648814fecf38f75c689172d7wrowestatic void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv)
0540a0b469147b52e858587270dba31c2aaa9e09wrowe proxy_server_conf *ps = apr_pcalloc(p, sizeof(proxy_server_conf));
053497224246c4dbef9af594cacf5c00ed271e6cwrowe proxy_server_conf *base = (proxy_server_conf *) basev;
0540a0b469147b52e858587270dba31c2aaa9e09wrowe proxy_server_conf *overrides = (proxy_server_conf *) overridesv;
aa047239dedf0d26e8efecfade32e7337f35df19wrowe ps->proxies = apr_array_append(p, base->proxies, overrides->proxies);
aa047239dedf0d26e8efecfade32e7337f35df19wrowe ps->sec_proxy = apr_array_append(p, base->sec_proxy, overrides->sec_proxy);
aa047239dedf0d26e8efecfade32e7337f35df19wrowe ps->aliases = apr_array_append(p, base->aliases, overrides->aliases);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ps->noproxies = apr_array_append(p, base->noproxies, overrides->noproxies);
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->dirconn = apr_array_append(p, base->dirconn, overrides->dirconn);
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->allowed_connect_ports = apr_array_append(p, base->allowed_connect_ports, overrides->allowed_connect_ports);
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->workers = apr_array_append(p, base->workers, overrides->workers);
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->balancers = apr_array_append(p, base->balancers, overrides->balancers);
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->forward = overrides->forward ? overrides->forward : base->forward;
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->reverse = overrides->reverse ? overrides->reverse : base->reverse;
aa047239dedf0d26e8efecfade32e7337f35df19wrowe ps->domain = (overrides->domain == NULL) ? base->domain : overrides->domain;
aa047239dedf0d26e8efecfade32e7337f35df19wrowe ps->viaopt = (overrides->viaopt_set == 0) ? base->viaopt : overrides->viaopt;
aa047239dedf0d26e8efecfade32e7337f35df19wrowe ps->viaopt_set = overrides->viaopt_set || base->viaopt_set;
aa047239dedf0d26e8efecfade32e7337f35df19wrowe ps->req = (overrides->req_set == 0) ? base->req : overrides->req;
aa047239dedf0d26e8efecfade32e7337f35df19wrowe ps->recv_buffer_size = (overrides->recv_buffer_size_set == 0) ? base->recv_buffer_size : overrides->recv_buffer_size;
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->recv_buffer_size_set = overrides->recv_buffer_size_set || base->recv_buffer_size_set;
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ps->io_buffer_size = (overrides->io_buffer_size_set == 0) ? base->io_buffer_size : overrides->io_buffer_size;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ps->io_buffer_size_set = overrides->io_buffer_size_set || base->io_buffer_size_set;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->maxfwd = (overrides->maxfwd_set == 0) ? base->maxfwd : overrides->maxfwd;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->maxfwd_set = overrides->maxfwd_set || base->maxfwd_set;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->error_override = (overrides->error_override_set == 0) ? base->error_override : overrides->error_override;
0540a0b469147b52e858587270dba31c2aaa9e09wrowe ps->error_override_set = overrides->error_override_set || base->error_override_set;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->preserve_host = (overrides->preserve_host_set == 0) ? base->preserve_host : overrides->preserve_host;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->preserve_host_set = overrides->preserve_host_set || base->preserve_host_set;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->timeout= (overrides->timeout_set == 0) ? base->timeout : overrides->timeout;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->timeout_set = overrides->timeout_set || base->timeout_set;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->badopt = (overrides->badopt_set == 0) ? base->badopt : overrides->badopt;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->badopt_set = overrides->badopt_set || base->badopt_set;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->proxy_status = (overrides->proxy_status_set == 0) ? base->proxy_status : overrides->proxy_status;
948096a99010fccf648814fecf38f75c689172d7wrowe ps->proxy_status_set = overrides->proxy_status_set || base->proxy_status_set;
948096a99010fccf648814fecf38f75c689172d7wrowestatic void *create_proxy_dir_config(apr_pool_t *p, char *dummy)
0540a0b469147b52e858587270dba31c2aaa9e09wrowe (proxy_dir_conf *) apr_pcalloc(p, sizeof(proxy_dir_conf));
0540a0b469147b52e858587270dba31c2aaa9e09wrowe /* Filled in by proxysection, when applicable */
948096a99010fccf648814fecf38f75c689172d7wrowe /* Put these in the dir config so they work inside <Location> */
0540a0b469147b52e858587270dba31c2aaa9e09wrowe new->raliases = apr_array_make(p, 10, sizeof(struct proxy_alias));
948096a99010fccf648814fecf38f75c689172d7wrowe new->cookie_paths = apr_array_make(p, 10, sizeof(struct proxy_alias));
948096a99010fccf648814fecf38f75c689172d7wrowe new->cookie_domains = apr_array_make(p, 10, sizeof(struct proxy_alias));
948096a99010fccf648814fecf38f75c689172d7wrowe new->cookie_path_str = apr_strmatch_precompile(p, "path=", 0);
948096a99010fccf648814fecf38f75c689172d7wrowe new->cookie_domain_str = apr_strmatch_precompile(p, "domain=", 0);
948096a99010fccf648814fecf38f75c689172d7wrowe return (void *) new;
a9a4544168a37b43bd180b3703ccee995f27a80awrowestatic void *merge_proxy_dir_config(apr_pool_t *p, void *basev, void *addv)
a9a4544168a37b43bd180b3703ccee995f27a80awrowe proxy_dir_conf *new = (proxy_dir_conf *) apr_pcalloc(p, sizeof(proxy_dir_conf));
948096a99010fccf648814fecf38f75c689172d7wrowe /* Put these in the dir config so they work inside <Location> */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb new->raliases = apr_array_append(p, base->raliases, add->raliases);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb = apr_array_append(p, base->cookie_paths, add->cookie_paths);
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowe = apr_array_append(p, base->cookie_domains, add->cookie_domains);
aa047239dedf0d26e8efecfade32e7337f35df19wrowe new->interpolate_env = (add->interpolate_env == -1) ? base->interpolate_env
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char *
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe add_proxy(cmd_parms *cmd, void *dummy, const char *f1, const char *r1, int regex)
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe char *p, *q;
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe char *r, *f, *scheme;
aa047239dedf0d26e8efecfade32e7337f35df19wrowe if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') {
aa047239dedf0d26e8efecfade32e7337f35df19wrowe return "ProxyRemoteMatch: Bad syntax for a remote proxy server";
aa047239dedf0d26e8efecfade32e7337f35df19wrowe return "ProxyRemote: Bad syntax for a remote proxy server";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (q != NULL) {
aa047239dedf0d26e8efecfade32e7337f35df19wrowe if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "ProxyRemoteMatch: Bad syntax for a remote proxy server (bad port number)";
aa047239dedf0d26e8efecfade32e7337f35df19wrowe return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)";
a9a4544168a37b43bd180b3703ccee995f27a80awrowe return "Regular expression for ProxyRemoteMatch could not be compiled.";
aa047239dedf0d26e8efecfade32e7337f35df19wrowestatic const char *
aa047239dedf0d26e8efecfade32e7337f35df19wrowe add_proxy_noregex(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
0540a0b469147b52e858587270dba31c2aaa9e09wrowestatic const char *
aa047239dedf0d26e8efecfade32e7337f35df19wrowe add_proxy_regex(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
aa047239dedf0d26e8efecfade32e7337f35df19wrowestatic const char *
aa047239dedf0d26e8efecfade32e7337f35df19wrowe add_pass(cmd_parms *cmd, void *dummy, const char *arg, int is_regex)
aa047239dedf0d26e8efecfade32e7337f35df19wrowe (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
aa047239dedf0d26e8efecfade32e7337f35df19wrowe while (*arg) {
aa047239dedf0d26e8efecfade32e7337f35df19wrowe return "ProxyPassMatch invalid syntax ('~' usage).";
0540a0b469147b52e858587270dba31c2aaa9e09wrowe else if (!r)
aa047239dedf0d26e8efecfade32e7337f35df19wrowe if (*r == '/') {
aa047239dedf0d26e8efecfade32e7337f35df19wrowe return "ProxyPass|ProxyPassMatch can not have a path when defined in "
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "a location.";
a9a4544168a37b43bd180b3703ccee995f27a80awrowe return "Invalid ProxyPass|ProxyPassMatch parameter. Parameter must "
a9a4544168a37b43bd180b3703ccee995f27a80awrowe "be in the form 'key=value'.";
aa047239dedf0d26e8efecfade32e7337f35df19wrowe return "Invalid ProxyPass|ProxyPassMatch parameter. Parameter must be "
aa047239dedf0d26e8efecfade32e7337f35df19wrowe "in the form 'key=value'.";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "ProxyPass|ProxyPassMatch needs a path when not defined in a location";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb new->regex = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "Regular expression could not be compiled.";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Distinguish the balancer from worker */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb proxy_balancer *balancer = ap_proxy_get_balancer(cmd->pool, conf, r);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe const char *err = set_balancer_param(conf, cmd->pool, balancer, elts[i].key,
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe proxy_worker *worker = ap_proxy_get_worker(cmd->temp_pool, conf, r);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe const char *err = ap_proxy_add_worker(&worker, cmd->pool, conf, r);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe "worker %s already used by another worker", worker->name);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe const char *err = set_worker_param(cmd->pool, worker, elts[i].key,
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowestatic const char *
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe add_pass_noregex(cmd_parms *cmd, void *dummy, const char *arg)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb add_pass_regex(cmd_parms *cmd, void *dummy, const char *arg)
68b29bcadd6c46aecdc9fe14c93555a2238ad2aagregamesstatic const char *
68b29bcadd6c46aecdc9fe14c93555a2238ad2aagregames add_pass_reverse(cmd_parms *cmd, void *dconf, const char *f, const char *r)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ( r == NULL)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "ProxyPassReverse needs a path when not defined in a location";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "ProxyPassReverse can not have a path when defined in a location";
48d2edbfb84e5559b5da0f8d614ccab805cc67a8rbbstatic const char*
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb cookie_path(cmd_parms *cmd, void *dconf, const char *f, const char *r)
b67fb549910fa0faf4cdd8aeaf9aeab51d4b6a92wrowestatic const char*
b67fb549910fa0faf4cdd8aeaf9aeab51d4b6a92wrowe cookie_domain(cmd_parms *cmd, void *dconf, const char *f, const char *r)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb set_proxy_exclude(cmd_parms *parms, void *dummy, const char *arg)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb struct noproxy_entry *list = (struct noproxy_entry *) conf->noproxies->elts;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Don't duplicate entries */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (strcasecmp(arg, list[i].name) == 0) { /* ignore case for host names */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (APR_SUCCESS == apr_sockaddr_info_get(&addr, new->name, APR_UNSPEC, 0, 0, parms->pool)) {
117026201e6d8fe7d82416b8a7324830f5a87292wrowe * Set the ports CONNECT can use
117026201e6d8fe7d82416b8a7324830f5a87292wrowestatic const char *
117026201e6d8fe7d82416b8a7324830f5a87292wrowe set_allowed_ports(cmd_parms *parms, void *dummy, const char *arg)
117026201e6d8fe7d82416b8a7324830f5a87292wrowe ap_get_module_config(s->module_config, &proxy_module);
117026201e6d8fe7d82416b8a7324830f5a87292wrowe return "AllowCONNECT: port number must be numeric";
e7505ba54ac56ae30e4e250f912f3dbaf92ca45fwrowe/* Similar to set_proxy_exclude(), but defining directly connected hosts,
cadddb2c31d24d48f4017db4df0a29687432326cwrowe * which should never be accessed via the configured ProxyRemote servers
cadddb2c31d24d48f4017db4df0a29687432326cwrowestatic const char *
cadddb2c31d24d48f4017db4df0a29687432326cwrowe set_proxy_dirconn(cmd_parms *parms, void *dummy, const char *arg)
efa1a34b0a7785fc72863eff175b0cfc1ecb0e38wrowe ap_get_module_config(s->module_config, &proxy_module);
beda1fb2f11c52ca4612460a5d5ba47398143efbwrowe struct dirconn_entry *list = (struct dirconn_entry *) conf->dirconn->elts;
beda1fb2f11c52ca4612460a5d5ba47398143efbwrowe /* Don't duplicate entries */
1067418d9ed9ed9daeb3ca4f74e72db810c49833wrowestatic const char *
1067418d9ed9ed9daeb3ca4f74e72db810c49833wrowe set_proxy_domain(cmd_parms *parms, void *dummy, const char *arg)
117026201e6d8fe7d82416b8a7324830f5a87292wrowe ap_get_module_config(parms->server->module_config, &proxy_module);
b67fb549910fa0faf4cdd8aeaf9aeab51d4b6a92wrowe return "ProxyDomain: domain name must start with a dot.";
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowestatic const char *
b45c1c292ff1fa635004ae81fa691f8cb3cdda85rbb ap_get_module_config(parms->server->module_config, &proxy_module);
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowestatic const char *
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe set_proxy_error_override(cmd_parms *parms, void *dummy, int flag)
2d2dadb81bf34e3bc9321eabcd971a738431b364wrowe ap_get_module_config(parms->server->module_config, &proxy_module);
5b3abd2fecc712f08ad728114aa77137b9f67716wrowestatic const char *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb set_preserve_host(cmd_parms *parms, void *dummy, int flag)
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe ap_get_module_config(parms->server->module_config, &proxy_module);
0540a0b469147b52e858587270dba31c2aaa9e09wrowestatic const char *
0540a0b469147b52e858587270dba31c2aaa9e09wrowe set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg)
0540a0b469147b52e858587270dba31c2aaa9e09wrowe ap_get_module_config(parms->server->module_config, &proxy_module);
0540a0b469147b52e858587270dba31c2aaa9e09wrowe if (s < 512 && s != 0) {
0540a0b469147b52e858587270dba31c2aaa9e09wrowe return "ProxyReceiveBufferSize must be >= 512 bytes, or 0 for system default.";
0540a0b469147b52e858587270dba31c2aaa9e09wrowestatic const char *
0540a0b469147b52e858587270dba31c2aaa9e09wrowe set_io_buffer_size(cmd_parms *parms, void *dummy, const char *arg)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_get_module_config(parms->server->module_config, &proxy_module);
5b3abd2fecc712f08ad728114aa77137b9f67716wrowe psf->io_buffer_size = ((s > AP_IOBUFSIZE) ? s : AP_IOBUFSIZE);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb set_max_forwards(cmd_parms *parms, void *dummy, const char *arg)
58097d7d8d1a394092374b9f6ddf76b7993724a4rbb ap_get_module_config(parms->server->module_config, &proxy_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (s < 0) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return "ProxyMaxForwards must be greater or equal to zero..";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char*
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb set_proxy_timeout(cmd_parms *parms, void *dummy, const char *arg)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_get_module_config(parms->server->module_config, &proxy_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "Proxy Timeout must be at least 1 second.";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char*
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb set_via_opt(cmd_parms *parms, void *dummy, const char *arg)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_get_module_config(parms->server->module_config, &proxy_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "ProxyVia must be one of: "
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "off | on | full | block";
return NULL;
return NULL;
return NULL;
char *word;
while (*arg) {
if (!path)
else if (!name)
if (!val)
if (!path)
if (!name)
if (!worker) {
const char *err;
if (err)
if (!balancer) {
if (err)
return NULL;
const char *err;
int in_proxy_section = 0;
if (!balancer) {
if (in_proxy_section) {
if (err)
if (!worker) {
if (in_proxy_section) {
if (err)
while (*arg) {
if (!val) {
if (worker)
if (err)
return NULL;
&proxy_module);
const char *errmsg;
return err;
if (!arg) {
return errmsg;
conf->r = r;
NULL);
NULL);
if (!balancer) {
if (err)
conf->p);
if (!worker) {
if (err)
NULL);
while (*arg) {
if (!val) {
if (worker)
if (err)
return NULL;
{NULL}
if (proxy_ssl_enable) {
if (proxy_ssl_disable) {
return proxy_ssl_disable(c);
if (proxy_is_https) {
return proxy_is_https(c);
const char *var)
if (proxy_ssl_val) {
return NULL;
return OK;
return OK;
++worker;
++balancer;
return OK;
worker++;
if (!reverse) {
s = s->next;
proxy_lb_workers = 0;
return OK;
request_rec *r,
request_rec *r,
(request_rec *r), (r),
(status, r),