优化代码
This commit is contained in:
parent
1f42bda2be
commit
bdc22baa47
|
|
@ -4,11 +4,39 @@
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ ./configure \
|
$ ./configure \
|
||||||
--prefix=/Users/wujp/Documents/workspaces/open-source/nginx-1.23.4/.nginx \
|
--prefix=$(PWD)/../build \
|
||||||
--add-module=/Users/wujp/Documents/workspaces/open-source/ip2region/binding/nginx
|
--add-module=$(PWD)/../ip2region/binding/nginx
|
||||||
|
|
||||||
$ make
|
$ make
|
||||||
$ make install
|
$ 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
|
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_create_conf(ngx_conf_t *cf);
|
||||||
static void ngx_http_ip2region_cleanup(void *data);
|
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);
|
ngx_command_t *cmd, void *conf);
|
||||||
|
|
||||||
static ngx_int_t ngx_http_ip2region_variable(ngx_http_request_t *r,
|
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[] = {
|
static ngx_command_t ngx_http_ip2region_commands[] = {
|
||||||
{ ngx_string("ip2region"),
|
{ ngx_string("ip2region"),
|
||||||
NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE12,
|
NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE12,
|
||||||
ngx_http_ip2region_processor,
|
ngx_http_ip2region_init,
|
||||||
NGX_HTTP_MAIN_CONF_OFFSET,
|
NGX_HTTP_MAIN_CONF_OFFSET,
|
||||||
0,
|
0,
|
||||||
NULL },
|
NULL },
|
||||||
|
|
@ -67,7 +67,7 @@ static ngx_http_variable_t ngx_http_ip2region_vars[] = {
|
||||||
|
|
||||||
|
|
||||||
static char *
|
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)
|
void *conf)
|
||||||
{
|
{
|
||||||
ngx_http_ip2region_conf_t *ip2region_cf;
|
ngx_http_ip2region_conf_t *ip2region_cf;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue