nginx 实现获取请求端的真实ip接口

server {
        listen       8910 ssl;
        server_name  localhost,xxx.xxx.com;
        client_max_body_size 2048m;

        #ssl on;
        ssl_certificate ssl/xxx.crt;
        ssl_certificate_key  ssl/xxx.key;
        ssl_protocols  SSLv2 SSLv3 TLSv1 TLSv1.2;
        ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

        gzip  on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 6;
        gzip_types       text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php application/javascript application/json image/jpeg image/jpg image/gif image/png;
        gzip_disable "MSIE [1-6]\.";
        gzip_vary on;

        # 获取请求端的真实ip
        location /myIp {
            return 200 "$remote_addr";
            default_type text/html;
        }
}

 

posted @ 2022-11-16 10:22  chenjianwen  阅读(265)  评论(0编辑  收藏  举报