⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_proxy.c

📁 apache 安装教程 apache 安装教程
💻 C
📖 第 1 页 / 共 3 页
字号:
        else {            ap_proxy_is_word(New, parms->pool);#if DEBUGGING            fprintf(stderr, "Parsed word %s\n", New->name);#endif        }    }    return NULL;}static const char *     set_proxy_domain(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    if (arg[0] != '.')        return "ProxyDomain: domain name must start with a dot.";    psf->domain = arg;    return NULL;}static const char *     set_proxy_req(cmd_parms *parms, void *dummy, int flag){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    psf->req = flag;    psf->req_set = 1;    return NULL;}static const char *     set_cache_size(cmd_parms *parms, char *struct_ptr, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    int val;    if (sscanf(arg, "%d", &val) != 1)        return "CacheSize value must be an integer (kBytes)";    psf->cache.space = val;    psf->cache.space_set = 1;    return NULL;}static const char *     set_cache_root(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    psf->cache.root = arg;    return NULL;}static const char *     set_cache_factor(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    double val;    if (sscanf(arg, "%lg", &val) != 1)        return "CacheLastModifiedFactor value must be a float";    psf->cache.lmfactor = val;    psf->cache.lmfactor_set = 1;    return NULL;}static const char *     set_cache_maxex(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    double val;    if (sscanf(arg, "%lg", &val) != 1)        return "CacheMaxExpire value must be a float";    psf->cache.maxexpire = (int)(val * (double)SEC_ONE_HR);    psf->cache.maxexpire_set = 1;    return NULL;}static const char *     set_cache_defex(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    double val;    if (sscanf(arg, "%lg", &val) != 1)        return "CacheDefaultExpire value must be a float";    psf->cache.defaultexpire = (int)(val * (double)SEC_ONE_HR);    psf->cache.defaultexpire_set = 1;    return NULL;}static const char *     set_cache_gcint(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    double val;    if (sscanf(arg, "%lg", &val) != 1)        return "CacheGcInterval value must be a float";    psf->cache.gcinterval = (int)(val * (double)SEC_ONE_HR);    psf->cache.gcinterval_set = 1;    return NULL;}static const char *     set_cache_dirlevels(cmd_parms *parms, char *struct_ptr, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    int val;    val = atoi(arg);    if (val < 1)        return "CacheDirLevels value must be an integer greater than 0";    if (val * psf->cache.dirlength > CACHEFILE_LEN)        return "CacheDirLevels*CacheDirLength value must not be higher than 20";    psf->cache.dirlevels = val;    psf->cache.dirlevels_set = 1;    return NULL;}static const char *     set_cache_dirlength(cmd_parms *parms, char *struct_ptr, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    int val;    val = atoi(arg);    if (val < 1)        return "CacheDirLength value must be an integer greater than 0";    if (val * psf->cache.dirlevels > CACHEFILE_LEN)        return "CacheDirLevels*CacheDirLength value must not be higher than 20";    psf->cache.dirlength = val;    psf->cache.dirlength_set = 1;    return NULL;}static const char *     set_cache_exclude(cmd_parms *parms, void *dummy, char *arg){    server_rec *s = parms->server;    proxy_server_conf *conf =    ap_get_module_config(s->module_config, &proxy_module);    struct nocache_entry *new;    struct nocache_entry *list = (struct nocache_entry *) conf->nocaches->elts;    struct hostent hp;    int found = 0;    int i;    /* Don't duplicate entries */    for (i = 0; i < conf->nocaches->nelts; i++) {        if (strcasecmp(arg, list[i].name) == 0) /* ignore case for host names */            found = 1;    }    if (!found) {        new = ap_push_array(conf->nocaches);        new->name = arg;        /* Don't do name lookups on things that aren't dotted */        if (strchr(arg, '.') != NULL && ap_proxy_host2addr(new->name, &hp) == NULL)            /*             * @@@FIXME: This copies only the first of (possibly many) IP             * addrs             */            memcpy(&new->addr, hp.h_addr, sizeof(struct in_addr));        else            new->addr.s_addr = 0;    }    return NULL;}static const char *     set_recv_buffer_size(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    int s = atoi(arg);    if (s < 512 && s != 0) {        return "ProxyReceiveBufferSize must be >= 512 bytes, or 0 for system default.";    }    psf->recv_buffer_size = s;    psf->recv_buffer_size_set = 1;    return NULL;}static const char *     set_io_buffer_size(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    long s = atol(arg);    psf->io_buffer_size = ((s > IOBUFSIZE) ? s : IOBUFSIZE);    psf->io_buffer_size_set = 1;    return NULL;}static const char *     set_cache_completion(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    int s = atoi(arg);    if (s > 100 || s < 0) {        return "CacheForceCompletion must be <= 100 percent, "            "or 0 for system default.";    }    if (s > 0)        psf->cache.cache_completion = ((float)s / 100);    psf->cache.cache_completion_set = 1;    return NULL;}static const char *     set_via_opt(cmd_parms *parms, void *dummy, char *arg){    proxy_server_conf *psf =    ap_get_module_config(parms->server->module_config, &proxy_module);    if (strcasecmp(arg, "Off") == 0)        psf->viaopt = via_off;    else if (strcasecmp(arg, "On") == 0)        psf->viaopt = via_on;    else if (strcasecmp(arg, "Block") == 0)        psf->viaopt = via_block;    else if (strcasecmp(arg, "Full") == 0)        psf->viaopt = via_full;    else {        return "ProxyVia must be one of: "            "off | on | full | block";    }    psf->viaopt_set = 1;    return NULL;}static const handler_rec proxy_handlers[] ={    {"proxy-server", proxy_handler},    {NULL}};static const command_rec proxy_cmds[] ={    {"ProxyRequests", set_proxy_req, NULL, RSRC_CONF, FLAG,    "on if the true proxy requests should be accepted"},    {"ProxyRemote", add_proxy, NULL, RSRC_CONF, TAKE2,    "a scheme, partial URL or '*' and a proxy server"},    {"ProxyPass", add_pass, NULL, RSRC_CONF, TAKE2,    "a virtual path and a URL"},    {"ProxyPassReverse", add_pass_reverse, NULL, RSRC_CONF, TAKE2,    "a virtual path and a URL for reverse proxy behaviour"},    {"ProxyBlock", set_proxy_exclude, NULL, RSRC_CONF, ITERATE,    "A list of names, hosts or domains to which the proxy will not connect"},    {"ProxyReceiveBufferSize", set_recv_buffer_size, NULL, RSRC_CONF, TAKE1,    "Receive buffer size for outgoing HTTP and FTP connections in bytes"},    {"ProxyIOBufferSize", set_io_buffer_size, NULL, RSRC_CONF, TAKE1,    "IO buffer size for outgoing HTTP and FTP connections in bytes"},    {"NoProxy", set_proxy_dirconn, NULL, RSRC_CONF, ITERATE,    "A list of domains, hosts, or subnets to which the proxy will connect directly"},    {"ProxyDomain", set_proxy_domain, NULL, RSRC_CONF, TAKE1,    "The default intranet domain name (in absence of a domain in the URL)"},    {"AllowCONNECT", set_allowed_ports, NULL, RSRC_CONF, ITERATE,    "A list of ports which CONNECT may connect to"},    {"CacheRoot", set_cache_root, NULL, RSRC_CONF, TAKE1,    "The directory to store cache files"},    {"CacheSize", set_cache_size, NULL, RSRC_CONF, TAKE1,    "The maximum disk space used by the cache in Kb"},    {"CacheMaxExpire", set_cache_maxex, NULL, RSRC_CONF, TAKE1,    "The maximum time in hours to cache a document"},    {"CacheDefaultExpire", set_cache_defex, NULL, RSRC_CONF, TAKE1,    "The default time in hours to cache a document"},    {"CacheLastModifiedFactor", set_cache_factor, NULL, RSRC_CONF, TAKE1,    "The factor used to estimate Expires date from LastModified date"},    {"CacheGcInterval", set_cache_gcint, NULL, RSRC_CONF, TAKE1,    "The interval between garbage collections, in hours"},    {"CacheDirLevels", set_cache_dirlevels, NULL, RSRC_CONF, TAKE1,    "The number of levels of subdirectories in the cache"},    {"CacheDirLength", set_cache_dirlength, NULL, RSRC_CONF, TAKE1,    "The number of characters in subdirectory names"},    {"NoCache", set_cache_exclude, NULL, RSRC_CONF, ITERATE,    "A list of names, hosts or domains for which caching is *not* provided"},    {"CacheForceCompletion", set_cache_completion, NULL, RSRC_CONF, TAKE1,    "Force a http cache completion after this percentage is loaded"},    {"ProxyVia", set_via_opt, NULL, RSRC_CONF, TAKE1,    "Configure Via: proxy header header to one of: on | off | block | full"},    {NULL}};module MODULE_VAR_EXPORT proxy_module ={    STANDARD_MODULE_STUFF,    proxy_init,                 /* initializer */    NULL,                       /* create per-directory config structure */    NULL,                       /* merge per-directory config structures */    create_proxy_config,        /* create per-server config structure */    merge_proxy_config,         /* merge per-server config structures */    proxy_cmds,                 /* command table */    proxy_handlers,             /* handlers */    proxy_trans,                /* translate_handler */    NULL,                       /* check_user_id */    NULL,                       /* check auth */    NULL,                       /* check access */    NULL,                       /* type_checker */    proxy_fixup,                /* pre-run fixups */    NULL,                       /* logger */    NULL,                       /* header parser */    NULL,                       /* child_init */    NULL,                       /* child_exit */    proxy_detect                /* post read-request */};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -