mirror of
https://github.com/netfun2000/ip2region.git
synced 2026-02-27 09:44:31 +08:00
优化代码
This commit is contained in:
@@ -4,11 +4,39 @@
|
||||
|
||||
```shell
|
||||
$ ./configure \
|
||||
--prefix=/Users/wujp/Documents/workspaces/open-source/nginx-1.23.4/.nginx \
|
||||
--add-module=/Users/wujp/Documents/workspaces/open-source/ip2region/binding/nginx
|
||||
--prefix=$(PWD)/../build \
|
||||
--add-module=$(PWD)/../ip2region/binding/nginx
|
||||
|
||||
$ make
|
||||
$ make install
|
||||
```
|
||||
|
||||
```nginx
|
||||
...
|
||||
http {
|
||||
|
||||
log_format json_access_log escape=json '{'
|
||||
'"remote_addr": "$remote_addr", '
|
||||
'"region": "$ip2region", '
|
||||
'"http_x_forwarded_for": "$http_x_forwarded_for"'
|
||||
'}';
|
||||
|
||||
access_log logs/access.log json_access_log;
|
||||
|
||||
# 设置xdb文件路径
|
||||
ip2region ip2region.xdb;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Made with ♥ by Wu Jian Ping
|
||||
|
||||
@@ -10,7 +10,7 @@ static ngx_int_t ngx_http_ip2region_add_variables(ngx_conf_t *cf);
|
||||
|
||||
static void *ngx_http_ip2region_create_conf(ngx_conf_t *cf);
|
||||
static void ngx_http_ip2region_cleanup(void *data);
|
||||
static char *ngx_http_ip2region_processor(ngx_conf_t *cf,
|
||||
static char *ngx_http_ip2region_init(ngx_conf_t *cf,
|
||||
ngx_command_t *cmd, void *conf);
|
||||
|
||||
static ngx_int_t ngx_http_ip2region_variable(ngx_http_request_t *r,
|
||||
@@ -31,7 +31,7 @@ static ngx_http_module_t ngx_http_ip2region_ctx = {
|
||||
static ngx_command_t ngx_http_ip2region_commands[] = {
|
||||
{ ngx_string("ip2region"),
|
||||
NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE12,
|
||||
ngx_http_ip2region_processor,
|
||||
ngx_http_ip2region_init,
|
||||
NGX_HTTP_MAIN_CONF_OFFSET,
|
||||
0,
|
||||
NULL },
|
||||
@@ -67,7 +67,7 @@ static ngx_http_variable_t ngx_http_ip2region_vars[] = {
|
||||
|
||||
|
||||
static char *
|
||||
ngx_http_ip2region_processor(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
ngx_http_ip2region_init(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf)
|
||||
{
|
||||
ngx_http_ip2region_conf_t *ip2region_cf;
|
||||
|
||||
Reference in New Issue
Block a user