ip2region_private/binding/nginx
Wu Jian Ping 9578720cd1 优化代码 2023-03-30 21:34:06 +08:00
..
src 优化代码 2023-03-30 21:34:06 +08:00
t nginx-impl init 2023-03-30 17:46:38 +08:00
LICENSE nginx-impl init 2023-03-30 17:46:38 +08:00
README.md 优化代码 2023-03-30 21:34:06 +08:00
config nginx-impl init 2023-03-30 17:46:38 +08:00

README.md

nginx-ip2region

编译

$ ./configure \
    --prefix=$(PWD)/../build \
    --add-module=$(PWD)/../ip2region/binding/nginx

$ make
$ make install
...
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