Created
June 17, 2012 13:17
-
-
Save hiboma/2944528 to your computer and use it in GitHub Desktop.
how to use mod_proxy's "proxy-server" handler in your custom Apache module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "httpd.h" | |
#include "http_config.h" | |
#include "http_protocol.h" | |
#include "ap_config.h" | |
#include "apr_strings.h" | |
#include "http_request.h" | |
static int reverse_proxy_handler(request_rec *r) | |
{ | |
r->filename = apr_pstrcat(r->pool, "proxy:http://example.com/", r->unparsed_uri, NULL); | |
r->proxyreq = PROXYREQ_REVERSE; | |
r->handler = "proxy-server"; | |
return OK; | |
} | |
static void reverse_proxy_register_hooks(apr_pool_t *p) | |
{ | |
ap_hook_fixups(reverse_proxy_handler, NULL, NULL, APR_HOOK_FIRST); | |
} | |
/* Dispatch list for API hooks */ | |
module AP_MODULE_DECLARE_DATA reverse_proxy_module = { | |
STANDARD20_MODULE_STUFF, | |
NULL, /* create per-dir config structures */ | |
NULL, /* merge per-dir config structures */ | |
NULL, /* create per-server config structures */ | |
NULL, /* merge per-server config structures */ | |
NULL, /* table of config file commands */ | |
reverse_proxy_register_hooks /* register hooks */ | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a bit buggy ,,,