View | Details | Raw Unified | Return to bug 37355
Collapse All | Expand All

(-)a/httpd/include/mod_proxy.h (-1 / +12 lines)
Lines 99-104 struct proxy_remote { Link Here
99
    const char *scheme;     /* the schemes handled by this proxy, or '*' */
99
    const char *scheme;     /* the schemes handled by this proxy, or '*' */
100
    const char *protocol;   /* the scheme used to talk to this proxy */
100
    const char *protocol;   /* the scheme used to talk to this proxy */
101
    const char *hostname;   /* the hostname of this proxy */
101
    const char *hostname;   /* the hostname of this proxy */
102
    const char *auth;           /* base64encode(<proxyuser>:<proxypasswd>) */
102
    ap_regex_t *regexp;     /* compiled regex (if any) for the remote */
103
    ap_regex_t *regexp;     /* compiled regex (if any) for the remote */
103
    int use_regex;          /* simple boolean. True if we have a regex pattern */
104
    int use_regex;          /* simple boolean. True if we have a regex pattern */
104
    apr_port_t  port;       /* the port for this proxy */
105
    apr_port_t  port;       /* the port for this proxy */
Lines 486-492 struct proxy_balancer_method { Link Here
486
487
487
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
488
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
488
                          proxy_worker *worker, proxy_server_conf *conf, char *url,
489
                          proxy_worker *worker, proxy_server_conf *conf, char *url,
489
                          const char *proxyhost, apr_port_t proxyport))
490
//                          const char *proxyhost, apr_port_t proxyport))
491
                          const char *proxyhost, apr_port_t proxyport,
492
                          const char *proxyauth))
493
490
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
494
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
491
                          char *url))
495
                          char *url))
492
496
Lines 720-725 PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker, Link Here
720
                                         proxy_server_conf *conf);
724
                                         proxy_server_conf *conf);
721
725
722
/**
726
/**
727
 * Request status function
728
 * @param status   status of proxy request
729
 * @return         OK or DECLINED
730
 */
731
 PROXY_DECLARE(int) ap_proxy_request_status(int *status, request_rec *r);
732
 
733
 /**
723
 * Determine backend hostname and port
734
 * Determine backend hostname and port
724
 * @param p       memory pool used for processing
735
 * @param p       memory pool used for processing
725
 * @param r       current request
736
 * @param r       current request
(-)a/httpd/modules/proxy/mod_proxy.c (-10 / +41 lines)
Lines 1011-1017 static int proxy_handler(request_rec *r) Link Here
1011
                    access_status = proxy_run_scheme_handler(r, worker,
1011
                    access_status = proxy_run_scheme_handler(r, worker,
1012
                                                             conf, url,
1012
                                                             conf, url,
1013
                                                             ents[i].hostname,
1013
                                                             ents[i].hostname,
1014
                                                             ents[i].port);
1014
//                                                             ents[i].port);
1015
                                                             ents[i].port,
1016
                                                             ents[i].auth);
1015
1017
1016
                    /* Did the scheme handler process the request? */
1018
                    /* Did the scheme handler process the request? */
1017
                    if (access_status != DECLINED) {
1019
                    if (access_status != DECLINED) {
Lines 1063-1069 static int proxy_handler(request_rec *r) Link Here
1063
                      scheme, attempts);
1065
                      scheme, attempts);
1064
        AP_PROXY_RUN(r, worker, conf, url, attempts);
1066
        AP_PROXY_RUN(r, worker, conf, url, attempts);
1065
        access_status = proxy_run_scheme_handler(r, worker, conf,
1067
        access_status = proxy_run_scheme_handler(r, worker, conf,
1066
                                                 url, NULL, 0);
1068
                                                 url, NULL, 0, NULL);
1069
//                                                 url, NULL, 0);
1067
        if (access_status == OK)
1070
        if (access_status == OK)
1068
            break;
1071
            break;
1069
        else if (access_status == HTTP_INTERNAL_SERVER_ERROR) {
1072
        else if (access_status == HTTP_INTERNAL_SERVER_ERROR) {
Lines 1285-1291 static const char * Link Here
1285
    proxy_server_conf *conf =
1288
    proxy_server_conf *conf =
1286
    (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
1289
    (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
1287
    struct proxy_remote *new;
1290
    struct proxy_remote *new;
1288
    char *p, *q;
1291
//    char *p, *q;
1292
    char *p, *q, *a;
1289
    char *r, *f, *scheme;
1293
    char *r, *f, *scheme;
1290
    ap_regex_t *reg = NULL;
1294
    ap_regex_t *reg = NULL;
1291
    int port;
1295
    int port;
Lines 1293-1298 static const char * Link Here
1293
    r = apr_pstrdup(cmd->pool, r1);
1297
    r = apr_pstrdup(cmd->pool, r1);
1294
    scheme = apr_pstrdup(cmd->pool, r1);
1298
    scheme = apr_pstrdup(cmd->pool, r1);
1295
    f = apr_pstrdup(cmd->pool, f1);
1299
    f = apr_pstrdup(cmd->pool, f1);
1300
    //   http://host:port
1296
    p = strchr(r, ':');
1301
    p = strchr(r, ':');
1297
    if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') {
1302
    if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') {
1298
        if (regex)
1303
        if (regex)
Lines 1301-1309 static const char * Link Here
1301
            return "ProxyRemote: Bad syntax for a remote proxy server";
1306
            return "ProxyRemote: Bad syntax for a remote proxy server";
1302
    }
1307
    }
1303
    else {
1308
    else {
1304
        scheme[p-r] = 0;
1309
//        scheme[p-r] = 0;
1310
        scheme[p-r] = '\0';
1305
    }
1311
    }
1306
    q = strchr(p + 3, ':');
1312
//    q = strchr(p + 3, ':');
1313
1314
    *p = '\0';   /* terminate r (scheme) */
1315
    p+=3;
1316
    /* may extract authentication string */
1317
    q = strchr(p, '@');
1318
    if (q != NULL) {
1319
        *q = '\0';
1320
        a = ap_pbase64encode(cmd->pool, p);
1321
        p = q;
1322
        p+=1;
1323
    }
1324
    else
1325
        a = NULL;
1326
1327
		q = strchr(p, ':');
1328
1307
    if (q != NULL) {
1329
    if (q != NULL) {
1308
        if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) {
1330
        if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) {
1309
            if (regex)
1331
            if (regex)
Lines 1315-1321 static const char * Link Here
1315
    }
1337
    }
1316
    else
1338
    else
1317
        port = -1;
1339
        port = -1;
1318
    *p = '\0';
1340
//    *p = '\0';
1341
1342
1319
    if (regex) {
1343
    if (regex) {
1320
        reg = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED);
1344
        reg = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED);
1321
        if (!reg)
1345
        if (!reg)
Lines 1324-1330 static const char * Link Here
1324
    else
1348
    else
1325
        if (strchr(f, ':') == NULL)
1349
        if (strchr(f, ':') == NULL)
1326
            ap_str_tolower(f);      /* lowercase scheme */
1350
            ap_str_tolower(f);      /* lowercase scheme */
1327
    ap_str_tolower(p + 3);      /* lowercase hostname */
1351
//    ap_str_tolower(p + 3);      /* lowercase hostname */
1352
    ap_str_tolower(p );      /* lowercase hostname */
1328
1353
1329
    if (port == -1) {
1354
    if (port == -1) {
1330
        port = apr_uri_port_of_scheme(scheme);
1355
        port = apr_uri_port_of_scheme(scheme);
Lines 1333-1340 static const char * Link Here
1333
    new = apr_array_push(conf->proxies);
1358
    new = apr_array_push(conf->proxies);
1334
    new->scheme = f;
1359
    new->scheme = f;
1335
    new->protocol = r;
1360
    new->protocol = r;
1336
    new->hostname = p + 3;
1361
//    new->hostname = p + 3;
1362
    new->hostname = p;
1337
    new->port = port;
1363
    new->port = port;
1364
    new->auth = a;
1338
    new->regexp = reg;
1365
    new->regexp = reg;
1339
    new->use_regex = regex;
1366
    new->use_regex = regex;
1340
    return NULL;
1367
    return NULL;
Lines 2539-2546 APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, scheme_handler, Link Here
2539
                                     (request_rec *r, proxy_worker *worker,
2566
                                     (request_rec *r, proxy_worker *worker,
2540
                                      proxy_server_conf *conf,
2567
                                      proxy_server_conf *conf,
2541
                                      char *url, const char *proxyhost,
2568
                                      char *url, const char *proxyhost,
2542
                                      apr_port_t proxyport),(r,worker,conf,
2569
//                                      apr_port_t proxyport),(r,worker,conf,
2543
                                      url,proxyhost,proxyport),DECLINED)
2570
//                                      url,proxyhost,proxyport),DECLINED)
2571
                                      apr_port_t proxyport,
2572
                                      const char *proxyauth
2573
                                      ),(r,worker,conf,
2574
                                      url,proxyhost,proxyport, proxyauth),DECLINED)
2544
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, canon_handler,
2575
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, canon_handler,
2545
                                      (request_rec *r, char *url),(r,
2576
                                      (request_rec *r, char *url),(r,
2546
                                      url),DECLINED)
2577
                                      url),DECLINED)
(-)a/httpd/modules/proxy/mod_proxy.h (-1 / +12 lines)
Lines 99-104 struct proxy_remote { Link Here
99
    const char *scheme;     /* the schemes handled by this proxy, or '*' */
99
    const char *scheme;     /* the schemes handled by this proxy, or '*' */
100
    const char *protocol;   /* the scheme used to talk to this proxy */
100
    const char *protocol;   /* the scheme used to talk to this proxy */
101
    const char *hostname;   /* the hostname of this proxy */
101
    const char *hostname;   /* the hostname of this proxy */
102
    const char *auth;           /* base64encode(<proxyuser>:<proxypasswd>) */
102
    ap_regex_t *regexp;     /* compiled regex (if any) for the remote */
103
    ap_regex_t *regexp;     /* compiled regex (if any) for the remote */
103
    int use_regex;          /* simple boolean. True if we have a regex pattern */
104
    int use_regex;          /* simple boolean. True if we have a regex pattern */
104
    apr_port_t  port;       /* the port for this proxy */
105
    apr_port_t  port;       /* the port for this proxy */
Lines 486-492 struct proxy_balancer_method { Link Here
486
487
487
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
488
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
488
                          proxy_worker *worker, proxy_server_conf *conf, char *url,
489
                          proxy_worker *worker, proxy_server_conf *conf, char *url,
489
                          const char *proxyhost, apr_port_t proxyport))
490
//                          const char *proxyhost, apr_port_t proxyport))
491
                          const char *proxyhost, apr_port_t proxyport,
492
                          const char *proxyauth))
493
490
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
494
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
491
                          char *url))
495
                          char *url))
492
496
Lines 720-725 PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker, Link Here
720
                                         proxy_server_conf *conf);
724
                                         proxy_server_conf *conf);
721
725
722
/**
726
/**
727
 * Request status function
728
 * @param status   status of proxy request
729
 * @return         OK or DECLINED
730
 */
731
 PROXY_DECLARE(int) ap_proxy_request_status(int *status, request_rec *r);
732
 
733
 /**
723
 * Determine backend hostname and port
734
 * Determine backend hostname and port
724
 * @param p       memory pool used for processing
735
 * @param p       memory pool used for processing
725
 * @param r       current request
736
 * @param r       current request
(-)a/httpd/modules/proxy/mod_proxy_connect.c (-1 / +17 lines)
Lines 194-200 static int proxy_connect_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o, Link Here
194
static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
194
static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
195
                                 proxy_server_conf *conf,
195
                                 proxy_server_conf *conf,
196
                                 char *url, const char *proxyname,
196
                                 char *url, const char *proxyname,
197
                                 apr_port_t proxyport)
197
//                                 apr_port_t proxyport)
198
                                 apr_port_t proxyport,
199
                                 const char *proxyauth
200
                                 )
198
{
201
{
199
    connect_conf *c_conf =
202
    connect_conf *c_conf =
200
        ap_get_module_config(r->server->module_config, &proxy_connect_module);
203
        ap_get_module_config(r->server->module_config, &proxy_connect_module);
Lines 384-389 static int proxy_connect_handler(request_rec *r, proxy_worker *worker, Link Here
384
                      "sending the CONNECT request to the remote proxy");
387
                      "sending the CONNECT request to the remote proxy");
385
        ap_fprintf(backconn->output_filters, bb,
388
        ap_fprintf(backconn->output_filters, bb,
386
                   "CONNECT %s HTTP/1.0" CRLF, r->uri);
389
                   "CONNECT %s HTTP/1.0" CRLF, r->uri);
390
391
392
      if (proxyauth) {
393
          ap_fprintf(backconn->output_filters, bb,
394
                               "Proxy-Authorization: Basic %s" CRLF,
395
                               proxyauth);
396
//         nbytes = apr_snprintf(buffer, sizeof(buffer),
397
//                               "Proxy-Authorization: Basic %s" CRLF,
398
//                               proxyauth);
399
//         apr_socket_send(sock, buffer, &nbytes);
400
      }
401
402
387
        ap_fprintf(backconn->output_filters, bb,
403
        ap_fprintf(backconn->output_filters, bb,
388
                   "Proxy-agent: %s" CRLF CRLF, ap_get_server_banner());
404
                   "Proxy-agent: %s" CRLF CRLF, ap_get_server_banner());
389
        ap_fflush(backconn->output_filters, bb);
405
        ap_fflush(backconn->output_filters, bb);
(-)a/httpd/modules/proxy/mod_proxy_http.c (-4 / +16 lines)
Lines 743-749 int ap_proxy_http_request(apr_pool_t *p, request_rec *r, Link Here
743
                                   proxy_conn_rec *p_conn, proxy_worker *worker,
743
                                   proxy_conn_rec *p_conn, proxy_worker *worker,
744
                                   proxy_server_conf *conf,
744
                                   proxy_server_conf *conf,
745
                                   apr_uri_t *uri,
745
                                   apr_uri_t *uri,
746
                                   char *url, char *server_portstr)
746
//                                   char *url, char *server_portstr)
747
                                   char *url, char *server_portstr,
748
                                   const char *proxyauth) 
747
{
749
{
748
    conn_rec *c = r->connection;
750
    conn_rec *c = r->connection;
749
    apr_bucket_alloc_t *bucket_alloc = c->bucket_alloc;
751
    apr_bucket_alloc_t *bucket_alloc = c->bucket_alloc;
Lines 1005-1010 int ap_proxy_http_request(apr_pool_t *p, request_rec *r, Link Here
1005
        APR_BRIGADE_INSERT_TAIL(header_brigade, e);
1007
        APR_BRIGADE_INSERT_TAIL(header_brigade, e);
1006
    }
1008
    }
1007
1009
1010
    if (proxyauth) {
1011
        buf = apr_pstrcat(p, "Proxy-Authorization: Basic ",
1012
                          proxyauth, CRLF, NULL);
1013
        ap_xlate_proto_to_ascii(buf, strlen(buf));
1014
        e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
1015
        APR_BRIGADE_INSERT_TAIL(header_brigade, e);
1016
    }
1017
1008
    /* We have headers, let's figure out our request body... */
1018
    /* We have headers, let's figure out our request body... */
1009
    input_brigade = apr_brigade_create(p, bucket_alloc);
1019
    input_brigade = apr_brigade_create(p, bucket_alloc);
1010
1020
Lines 2129-2135 apr_status_t ap_proxy_http_cleanup(const char *scheme, request_rec *r, Link Here
2129
static int proxy_http_handler(request_rec *r, proxy_worker *worker,
2139
static int proxy_http_handler(request_rec *r, proxy_worker *worker,
2130
                              proxy_server_conf *conf,
2140
                              proxy_server_conf *conf,
2131
                              char *url, const char *proxyname,
2141
                              char *url, const char *proxyname,
2132
                              apr_port_t proxyport)
2142
//                              apr_port_t proxyport)
2143
                              apr_port_t proxyport, const char *proxyauth)
2133
{
2144
{
2134
    int status;
2145
    int status;
2135
    char server_portstr[32];
2146
    char server_portstr[32];
Lines 2246-2252 static int proxy_http_handler(request_rec *r, proxy_worker *worker, Link Here
2246
         * kinda HTTP ping test, allow for retries
2257
         * kinda HTTP ping test, allow for retries
2247
         */
2258
         */
2248
        if ((status = ap_proxy_http_request(p, r, backend, worker,
2259
        if ((status = ap_proxy_http_request(p, r, backend, worker,
2249
                                        conf, uri, locurl, server_portstr)) != OK) {
2260
//                                        conf, uri, locurl, server_portstr)) != OK) {
2261
                                        conf, uri, locurl, server_portstr, (is_ssl ? NULL : proxyauth)
2262
                                        )) != OK) {
2250
            if ((status == HTTP_SERVICE_UNAVAILABLE) && worker->s->ping_timeout_set) {
2263
            if ((status == HTTP_SERVICE_UNAVAILABLE) && worker->s->ping_timeout_set) {
2251
                backend->close = 1;
2264
                backend->close = 1;
2252
                ap_log_rerror(APLOG_MARK, APLOG_INFO, status, r, APLOGNO(01115)
2265
                ap_log_rerror(APLOG_MARK, APLOG_INFO, status, r, APLOGNO(01115)
2253
- 

Return to bug 37355