]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
hook into mod_ssl for https support
authorDoug MacEachern <dougm@apache.org>
Fri, 29 Mar 2002 07:29:11 +0000 (07:29 +0000)
committerDoug MacEachern <dougm@apache.org>
Fri, 29 Mar 2002 07:29:11 +0000 (07:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94300 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/proxy_http.c

index 5daef69d5b31128754daf45e665f489775ef6902..a9613ddf87d87c3c6fd5ac8b241c1650c1fc64c7 100644 (file)
@@ -61,6 +61,8 @@
 #include "mod_proxy.h"
 #include "mod_core.h"
 
+#include "apr_optional.h"
+
 extern module AP_MODULE_DECLARE_DATA proxy_module;
 
 #ifndef MAX
@@ -1045,6 +1047,23 @@ static const command_rec proxy_cmds[] =
     {NULL}
 };
 
+APR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *));
+
+static APR_OPTIONAL_FN_TYPE(ssl_proxy_enable) *proxy_ssl_enable = NULL;
+
+int ap_proxy_ssl_enable(conn_rec *c)
+{
+    /* 
+     * if c == NULL just check if the optional function was imported
+     * else run the optional function so ssl filters are inserted
+     */
+    if (proxy_ssl_enable) {
+        return c ? proxy_ssl_enable(c) : 1;
+    }
+
+    return 0;
+}
+
 static void register_hooks(apr_pool_t *p)
 {
     /* handler */
@@ -1057,6 +1076,8 @@ static void register_hooks(apr_pool_t *p)
     ap_hook_fixups(proxy_fixup, NULL, NULL, APR_HOOK_FIRST);
     /* post read_request handling */
     ap_hook_post_read_request(proxy_detect, NULL, NULL, APR_HOOK_FIRST);
+
+    proxy_ssl_enable = APR_RETRIEVE_OPTIONAL_FN(ssl_proxy_enable);
 }
 
 module AP_MODULE_DECLARE_DATA proxy_module =
index b9d18bcacc3f5b261cde3d960cbe0cbda0f15bbd..ccd6b1c35a4930fe12e2c3466faf3234ac8bd097 100644 (file)
@@ -208,6 +208,7 @@ typedef struct {
     conn_rec *connection;
     char *hostname;
     apr_port_t port;
+    int is_ssl;
 } proxy_conn_rec;
 
 typedef struct {
@@ -273,5 +274,6 @@ PROXY_DECLARE(apr_status_t) ap_proxy_string_read(conn_rec *c, apr_bucket_brigade
 PROXY_DECLARE(void) ap_proxy_reset_output_filters(conn_rec *c);
 PROXY_DECLARE(void) ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *key);
 PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **, const char *, apr_sockaddr_t *, const char *, proxy_server_conf *, server_rec *, apr_pool_t *);
+PROXY_DECLARE(int) ap_proxy_ssl_enable(conn_rec *c);
 
 #endif /*MOD_PROXY_H*/
index e57ffc3ea96b84260367e90cd4d55d935c1e22ba..f37785d4ad7f32e1be56edd0b160121a7b23c167 100644 (file)
@@ -391,6 +391,10 @@ apr_status_t ap_proxy_http_create_connection(apr_pool_t *p, request_rec *r,
         backend->hostname = apr_pstrdup(c->pool, p_conn->name);
         backend->port = p_conn->port;
 
+        if (backend->is_ssl) {
+            ap_proxy_ssl_enable(backend->connection);
+        }
+
         ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
                      "proxy: connection complete to %pI (%s)",
                      p_conn->addr, p_conn->name);
@@ -937,6 +941,7 @@ int ap_proxy_http_handler(request_rec *r, proxy_server_conf *conf,
     char server_portstr[32];
     conn_rec *origin = NULL;
     proxy_conn_rec *backend = NULL;
+    int is_ssl = 0;
 
     /* Note: Memory pool allocation.
      * A downstream keepalive connection is always connected to the existence
@@ -959,7 +964,16 @@ int ap_proxy_http_handler(request_rec *r, proxy_server_conf *conf,
                                            sizeof(*p_conn));
 
     /* is it for us? */
-    if (strncasecmp(url, "http:", 5)) {
+    if (strncasecmp(url, "https:", 6) == 0) {
+        if (!ap_proxy_ssl_enable(NULL)) {
+            ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
+                         "proxy: HTTPS: declining URL %s"
+                         " (mod_ssl not configured?)", url);
+            return DECLINED;
+        }
+        is_ssl = 1;
+    }
+    else if (strncasecmp(url, "http:", 5)) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
                      "proxy: HTTP: declining URL %s", url);
         return DECLINED; /* only interested in HTTP */
@@ -986,6 +1000,8 @@ int ap_proxy_http_handler(request_rec *r, proxy_server_conf *conf,
         }
     }
 
+    backend->is_ssl = is_ssl;
+
     /* Step One: Determine Who To Connect To */
     status = ap_proxy_http_determine_connection(p, r, p_conn, c, conf, uri,
                                                 &url, proxyname, proxyport,