--- include/http_core.h (revision 1586662) +++ include/http_core.h (working copy) @@ -692,6 +692,11 @@ #define AP_HTTP_EXPECT_STRICT_ENABLE 1 #define AP_HTTP_EXPECT_STRICT_DISABLE 2 int http_expect_strict; + +#define AP_EXPORT_SERVER_ADDR_UNSET 0 +#define AP_EXPORT_SERVER_ADDR_ENABLE 1 +#define AP_EXPORT_SERVER_ADDR_DISABLE 2 + int export_server_addr; } core_server_config; /* for AddOutputFiltersByType in core.c */ --- server/core.c (revision 1586662) +++ server/core.c (working copy) @@ -525,6 +525,9 @@ if (virt->http_expect_strict != AP_HTTP_EXPECT_STRICT_UNSET) conf->http_expect_strict = virt->http_expect_strict; + if (virt->export_server_addr != AP_EXPORT_SERVER_ADDR_UNSET) + conf->export_server_addr = virt->export_server_addr; + /* no action for virt->accf_map, not allowed per-vhost */ if (virt->protocol) @@ -3806,6 +3809,19 @@ return NULL; } +static const char *set_export_server_addr(cmd_parms *cmd, void *dummy, int arg) +{ + core_server_config *conf = + ap_get_core_module_config(cmd->server->module_config); + + if (arg) { + conf->export_server_addr = AP_EXPORT_SERVER_ADDR_ENABLE; + } else { + conf->export_server_addr = AP_EXPORT_SERVER_ADDR_DISABLE; + } + return NULL; +} + static apr_hash_t *errorlog_hash; static int log_constant_item(const ap_errorlog_info *info, const char *arg, @@ -4367,6 +4383,8 @@ "whether to permit Content-Length of 0 responses to HEAD requests"), AP_INIT_FLAG("HttpExpectStrict", set_expect_strict, NULL, OR_OPTIONS, "whether to return a 417 if a client doesn't send 100-Continue"), +AP_INIT_FLAG("ExportServerAddr", set_export_server_addr, NULL, RSRC_CONF, + "whether to export the SERVER_ADDR environment variable"), { NULL } }; --- server/util_script.c (revision 1586662) +++ server/util_script.c (working copy) @@ -140,6 +140,7 @@ apr_table_t *e; server_rec *s = r->server; conn_rec *c = r->connection; + core_server_config *conf = ap_get_core_module_config(s->module_config); const char *env_temp; const apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in); const apr_table_entry_t *hdrs = (const apr_table_entry_t *) hdrs_arr->elts; @@ -232,7 +233,9 @@ apr_table_addn(e, "SERVER_SOFTWARE", ap_get_server_banner()); apr_table_addn(e, "SERVER_NAME", ap_escape_html(r->pool, ap_get_server_name_for_url(r))); - apr_table_addn(e, "SERVER_ADDR", r->connection->local_ip); /* Apache */ + if (conf->export_server_addr != AP_EXPORT_SERVER_ADDR_DISABLE) { + apr_table_addn(e, "SERVER_ADDR", r->connection->local_ip); /* Apache */ + } apr_table_addn(e, "SERVER_PORT", apr_psprintf(r->pool, "%u", ap_get_server_port(r))); add_unless_null(e, "REMOTE_HOST",