On Fri, Oct 25, 2013 at 9:16 AM, Jeff Trawick <[email protected]> wrote:
> On Fri, Oct 25, 2013 at 9:07 AM, Daniel Ruggeri <[email protected]>wrote: > >> As I stand up a simple IPv6 test proxy that supports both AF_INET and >> AF_INET6 addresses, I was looking for a way to log what addr family (and >> maybe the IP address) mod_proxy settled on for each request in the >> access_log. I'm not seeing a way to do that (but correct me if I'm >> missing something) and was poking through the code and got to thinking >> that there are all kinds of data bits that'd be interesting to have >> available in the ENV. >> >> I'm thinking it'd be worth adding a directive (ProxyAddEnvironment?) >> that adds these ENV entries to each r->subprocess_env: >> * Host header sent to backend (useful when dynamic targets are used) >> * Target DNS name if set >> * Target IP address >> * Target Address family >> * Target port >> * Target connection protocol >> * Flag for SSL enabled >> >> All of the data is readily available once a connection is acquired in >> ap_proxy_acquire_connection sans the HTTP Host header. >> Aside from logging, exporting these as ENV entries to the request allows >> us to do all sorts of stuff in other modules, too.... >> >> Any thoughts? Is there something I should include or exclude before I >> begin? >> >> -- >> Daniel Ruggeri >> >> > (unrefined, right out of my ... head) > > useful to have a convention (if not API) for how this info is made > available for logging, etc., so that other modules can play the same game > (e.g., mod_jk, FastCGI, whatever) > > what about a plugin with optional functions that has APIs for recording > backend state that is meaningful across variety of "gateway" modules? for > now maybe it is just for logging, but it could save in shared memory for > extraction in mod_status or other reports > > maybe that solution is a bit farfetched, but I guess the theme is that > creating a proxy-specific solution can be a wasted effort given the same > need for any number of other "gateway" modules > > -- > Born in Roswell... married an alien... > http://emptyhammock.com/ > A little more refined... (see attached .h file) It wouldn't take too many lines of code to provide logging (custom access log format with various format strings). A "few" more and it is in shared memory for a scoreboard display so you can see where your requests are getting stalled when talking to LDAP servers or app servers or whatever... Having a callable API for modules will help with consistency of representation and largely eliminate questions of what can/should be represented. -- Born in Roswell... married an alien... http://emptyhammock.com/
/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_backend_state.h * @brief State collection and report services for modules which communicate * with backend servers * * @defgroup MOD_BACKEND_STATE mod_backend_state * @ingroup APACHE_MODS * @{ */ #ifndef MOD_BACKEND_STATE_H #define MOD_BACKEND_STATE_H #include "httpd.h" #include "apr_optional.h" #ifdef __cplusplus extern "C" { #endif typedef enum { BS_PHASE_CERT_VAL, BS_PHASE_AUTHN, BS_PHASE_AUTHZ, BS_PHASE_HANDLER, BS_PHASE_FILTER_IN, BS_PHASE_FILTER_OUT, } backend_state_phase; typedef enum { BS_SUBPHASE_GENERIC, BS_SUBPHASE_LOOKUP, BS_SUBPHASE_CONNECT, BS_SUBPHASE_WRITE_FIRST, BS_SUBPHASE_WRITE_MORE, BS_SUBPHASE_READ_FIRST, BS_SUBPHASE_READ_MORE, BS_SUBPHASE_CLOSING, } backend_state_subphase; #define BS_PROTOCOL_HTTPS "https" #define BS_PROTOCOL_HTTP "http" #define BS_PROTOCOL_AJP "ajp" #define BS_PROTOCOL_FASTCGI "fcgi" /* or some custom string */ /** * State reporting function. * Call this when a peer is determined or when connection/request * processing phase or subphase changes. */ APR_DECLARE_OPTIONAL_FN(int,backend_state,(conn_rec *c, request_rec *r, backend_state_phase, backend_state_subphase, apr_sockaddr_t *peer, const char *protocol)); /** * Data transfer reporting function. * Call this to report additional (or initial) bytes transferred * in either direction. */ APR_DECLARE_OPTIONAL_FN(int,backend_io_xfer,(conn_rec *c, request_rec *r, apr_size_t more_bytes_read, apr_size_t more_bytes_written)); #ifdef __cplusplus } #endif #endif /** @} */
