Hi,

Is there a way to override http proxy handling to use a different module
other then mod_proxy_http?  IĀ¹ve been trying to use apache as a forwarding
proxy but I have an issue with the way it handles connection refused cases
from a server. 

I believe my issue lies within the code section below from the
proxy_http_handler  function in mod_proxy_http.c but I want to make sure I
understand this correctly.

Step One is looking up the address of the server to contact on behalf of the
client, if it cannot find an address for  the server it fails and goes onto
cleanup which will send OstatusĀ¹ back to the client.

Getting to Step Two means that it found an address and Step Two itself is
going to attempt to make the initial connection to that address.  My issue
then comes into play where the address of a server is known but the server
could refuse the connection on a particular port for some reason such as the
site is down, or whatever.   If this happens and Apache is configured to
ProxyRequests, the status is set to HTTP_NOT_FOUND, which really isnt the
case, the server refused the connection it's not that the page wasn't found.


Am I mistaken is thinking that r->proxyreq == PROXYREQ_PROXY  is always true
when ProxyRequests is set to On in the configuration? If so how do I force
the HTTP_SERVICE_UNAVAILABLE instead of the HTTP_NOT_FOUND? Do I have to
patch this myself and recompile it? And if I do can I simpley change the
name of the module to something like my_mod_proxy_http and in the apache
config simply comment out the original and add mine?


Thanks 

Rob


static int proxy_http_handler(request_rec *r, proxy_worker *worker,
                              proxy_server_conf *conf,
                              char *url, const char *proxyname,
                              apr_port_t proxyport)
{

.......
......
.....


  /* Step One: Determine Who To Connect To */
    if ((status = ap_proxy_determine_connection(p, r, conf, worker, backend,
                                                uri, &url, proxyname,
                                                proxyport, server_portstr,
                                                sizeof(server_portstr))) !=
OK)
        goto cleanup;

    /* Step Two: Make the Connection */
    if (ap_proxy_connect_backend(proxy_function, backend, worker,
r->server)) {
        if (r->proxyreq == PROXYREQ_PROXY)
            status = HTTP_NOT_FOUND;
        else
            status = HTTP_SERVICE_UNAVAILABLE;
        goto cleanup;
    }


  /* Step Three: Create conn_rec */
    if (!backend->connection) {
        if ((status = ap_proxy_connection_create(proxy_function, backend,
                                                 c, r->server)) != OK)
            goto cleanup;
    }

    /* Step Four: Send the Request */
    if ((status = ap_proxy_http_request(p, r, backend, backend->connection,
                                        conf, uri, url, server_portstr)) !=
OK)
        goto cleanup;

    /* Step Five: Receive the Response */
    if ((status = ap_proxy_http_process_response(p, r, backend,
                                                 backend->connection,
                                                 conf, server_portstr)) !=
OK)
        goto cleanup;


.....
.....
.....

Reply via email to