apache取得客户端ip

今天修改下so,搞ip,找了半天,发现了request_rec结构体里面有,记录下。

struct request_rec { 
    pool *pool; 
    conn_rec *connection; 
    server_rec *server; 
    request_rec *next; 
    request_rec *prev; 
    request_rec *main; 
    char *the_request; 
    int assbackwards; 
    enum proxyreqtype proxyreq; 
    int header_only; 
    char *protocol; 
    int proto_num; 
    char *hostname; 
    time_t request_time; 
    const char *status_line; 
    int status; 
    const char *method; 
    int method_number; 
    int allowed; 
    int sent_bodyct; 
    long bytes_sent; 
    time_t mtime; 
    int chunked; 
    int byterange; 
    char *boundary; 
    const char *range; 
    long clength; 
    long remaining; 
    long read_length; 
    int read_body; 
    int read_chunked; 
    unsigned expecting_100; 
    table *headers_in; 
    table *headers_out; 
    table *err_headers_out; 
    table *subprocess_env; 
    table *notes; 
    const char *content_type; 
    const char *handler; 
    const char *content_encoding; 
    const char *content_language; 
    array_header *content_languages; 
    char *vlist_validator; 
    int no_cache; 
    int no_local_copy; 
    char *unparsed_uri; 
    char *uri; 
    char *filename; 
    char *path_info; 
    char *args; 
    struct stat finfo; 
    uri_components parsed_uri; 
    void *per_dir_config; 
    void *request_config; 
    const struct htaccess_result *htaccess; 
    char *case_preserved_filename; 
};
typedef struct conn_rec conn_rec; 
struct conn_rec { 
    pool *pool; 
    server_rec *server; 
    server_rec *base_server; 
    void *vhost_lookup_data; 
    int child_num; 
    BUFF *client; 
    struct sockaddr_in local_addr; 
    struct sockaddr_in remote_addr; 
    char *remote_ip; 
    char *remote_host; 
    char *remote_logname; 
    char *user; 
    char *ap_auth_type; 
    unsigned aborted:1; 
    signed int keepalive:2; 
    unsigned keptalive:1; 
    signed int double_reverse:2; 
    int keepalives; 
    char *local_ip; 
    char *local_host; 
};
想打印出来看下,直接用
fprintf(stderr,"%s/n",r->connection->remote_ip);
打印到apache的日志中,日志中竟然没有记录,只好单独打印到一个文件中看下了。尴尬
 

你可能感兴趣的:(apache,struct,server,table,subprocess,Components)