long maxfwd;
proxy_balancer *balancer = NULL;
proxy_worker *worker = NULL;
- proxy_module_conf *mconf;
/* is this for us? */
if (!r->proxyreq || !r->filename || strncmp(r->filename, "proxy:", 6) != 0)
if (access_status != OK)
return access_status;
- /* only use stored info for top-level pages. Sub requests don't share
- * in keepalives
- */
- if (!r->main) {
- mconf = (proxy_module_conf *)ap_get_module_config(r->connection->conn_config,
- &proxy_module);
- }
- /* create space for state information */
- if (!mconf) {
- mconf = apr_pcalloc(r->connection->pool, sizeof(proxy_module_conf));
- if (!r->main) {
- ap_set_module_config(r->connection->conn_config,
- &proxy_module, mconf);
- }
- }
- /* use the current balancer and worker.
- * the proxy_conn will be set in particular scheme handler
- * if not already set.
- */
- mconf->balancer = balancer;
- mconf->worker = worker;
- mconf->url = url;
-
/* firstly, try a proxy, unless a NoProxy directive is active */
if (!direct_connect) {
for (i = 0; i < proxies->nelts; i++) {
typedef struct proxy_balancer proxy_balancer;
typedef struct proxy_worker proxy_worker;
-typedef struct proxy_conn proxy_conn;
typedef struct proxy_conn_pool proxy_conn_pool;
typedef struct {
#endif
};
-/* per connection data structure for set/get module_config */
-typedef struct {
- char *url; /* rewtitten url */
- struct proxy_balancer *balancer; /* load balancer to use */
- proxy_worker *worker; /* most suitable worker */
- proxy_conn_rec *conn_rec;
- proxy_conn *conn;
- void *opaque; /* module private data */
-} proxy_module_conf;
-
/* hooks */
/* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and
PROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer, apr_pool_t *p, proxy_server_conf *conf, const char *url);
PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(proxy_balancer *balancer, proxy_worker *worker);
PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker, proxy_balancer **balancer, request_rec *r, proxy_server_conf *conf, char **url);
-PROXY_DECLARE(apr_status_t) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r, proxy_server_conf *conf, proxy_module_conf *mconf,
+PROXY_DECLARE(apr_status_t) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r, proxy_server_conf *conf, proxy_worker *worker, proxy_conn_rec *conn,
apr_pool_t *ppool, apr_uri_t *uri, char **url, const char *proxyname, apr_port_t proxyport,
char *server_portstr, int server_portstr_size);
PROXY_DECLARE(apr_status_t)
ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
proxy_server_conf *conf,
- proxy_module_conf *mconf,
+ proxy_worker *worker,
+ proxy_conn_rec *conn,
apr_pool_t *ppool,
apr_uri_t *uri,
char **url,
*/
/* are we connecting directly, or via a proxy? */
if (proxyname) {
- mconf->conn_rec->hostname = apr_pstrdup(ppool, proxyname);
- mconf->conn_rec->port = proxyport;
+ conn->hostname = apr_pstrdup(ppool, proxyname);
+ conn->port = proxyport;
} else {
- mconf->conn_rec->hostname = apr_pstrdup(ppool, uri->hostname);
- mconf->conn_rec->port = uri->port;
+ conn->hostname = apr_pstrdup(ppool, uri->hostname);
+ conn->port = uri->port;
*url = apr_pstrcat(p, uri->path, uri->query ? "?" : "",
uri->query ? uri->query : "",
uri->fragment ? "#" : "",
* If dynamic change is needed then set the addr to NULL
* inside dynamic config to force the lookup.
*/
- if (!mconf->worker->cp->addr)
- err = apr_sockaddr_info_get(&(mconf->worker->cp->addr),
- mconf->conn_rec->hostname, APR_UNSPEC,
- mconf->conn_rec->port, 0,
- mconf->worker->cp->pool);
+ if (!worker->cp->addr)
+ err = apr_sockaddr_info_get(&(worker->cp->addr),
+ conn->hostname, APR_UNSPEC,
+ conn->port, 0,
+ worker->cp->pool);
if (err != APR_SUCCESS) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
apr_pstrcat(p, "DNS lookup failure for: ",
- mconf->conn_rec->hostname, NULL));
+ conn->hostname, NULL));
}
/* Get the server port for the Via headers */
}
/* check if ProxyBlock directive on this host */
- if (OK != ap_proxy_checkproxyblock(r, conf, mconf->worker->cp->addr)) {
+ if (OK != ap_proxy_checkproxyblock(r, conf, worker->cp->addr)) {
return ap_proxyerror(r, HTTP_FORBIDDEN,
"Connect to remote machine blocked");
}