Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

全局统计没数据 #408

Closed
boot-vue opened this issue Jan 14, 2020 · 7 comments
Closed

全局统计没数据 #408

boot-vue opened this issue Jan 14, 2020 · 7 comments

Comments

@boot-vue
Copy link

image

安装完没配置任何规则, request请求一直都是 1

orange dashboard 通过ip:9999访问

web通过 域名访问的 起码每秒有10多个访问

@boot-vue
Copy link
Author

还需要其它配置吗

access.log 有数据 error.log没有任何错误

@boot-vue
Copy link
Author

resty 0.23
nginx version: openresty/1.15.8.2
built by gcc 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
built with OpenSSL 1.1.0k  28 May 2019
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' --add-module=../ngx_devel_kit-0.3.1rc1 --add-module=../echo-nginx-module-0.61 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.15 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../ngx_stream_lua-0.0.7 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl/lib' --with-cc='ccache gcc -fdiagnostics-color=always' --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-dtrace-probes --with-stream --with-stream_ssl_preread_module --with-http_ssl_module

http_stub_status也有

@769344359
Copy link
Contributor

@boot-vue 试试请求你监听的端口,比如80 或者443

@boot-vue
Copy link
Author

@boot-vue 试试请求你监听的端口,比如80 或者443

比如服务器 2.2.2.2 , nginx.conf 里边配置了域名 443 https://www.baidu.com

http://2.2.2.2:9999 访问dashboard

https://www.baidu.com 一天怎么滴也有上万的请求 , 但是dashboard里 total request 一直都是 1 不变

orange start , access.log , error.log 都正常, 没有什么异常

@boot-vue
Copy link
Author

boot-vue commented Jan 15, 2020

nginx.conf 大概就这样, https://www.baidu.com 访问了上万次也没反应

worker_processes auto;
user root;

events {
    worker_connections  4096;
}

# optional: path of orange.conf
env ORANGE_CONF;

http {
    resolver 8.8.8.8; # replace it with your favorite config
    charset UTF-8;
    include ./mime.types;

    log_format  main '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$request_time" "$ssl_protocol" "$ssl_cipher" "$http_x_forwarded_for"'
    '"$upstream_addr" "$upstream_status" "$upstream_response_length" "$upstream_response_time"';

    access_log  ./logs/access.log  main;
    error_log ./logs/error.log error;

    sendfile        on;
    keepalive_timeout  65;

    upstream default_upstream {
        server localhost:8001;
    }

    #
    # Config client_body_buffer_size equal client_max_body_size for enforcing in-memory buffering of the whole request body
    # ref: https://github.com/openresty/lua-nginx-module/issues/521
    #
    # official instruct docs http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size
    #
    client_body_buffer_size 1m;
    client_max_body_size 1m;

    #----------------------------Orange configuration-----------------------------
    lua_package_path  "$prefix/deps/share/lua/5.1/?.lua;$prefix/deps/share/lua/5.1/orange/?.lua;$prefix/?.lua;/usr/share/lua/5.1/?.lua;/usr/local/lor/?.lua;;";
    lua_package_cpath "$prefix/deps/lib64/lua/5.1/?.so;$prefix/deps/lib/lua/5.1/?.so;/usr/lib64/lua/5.1/?.so;;";
    lua_code_cache on;

    lua_shared_dict orange_data 20m; # should not removed. used for orange data, e.g. plugins configurations..

    lua_shared_dict status 1m; # used for global statistic, see plugin: stat
    lua_shared_dict waf_status 1m; # used for waf statistic, see plugin: waf
    lua_shared_dict monitor 10m; # used for url monitor statistic, see plugin: monitor
    lua_shared_dict rate_limit 10m; # used for rate limiting count, see plugin: rate_limiting
    lua_shared_dict property_rate_limiting 10m; # used for rate limiting count, see plugin: rate_limiting



    init_by_lua_block {
        local orange = require("orange.orange")
        local env_orange_conf = os.getenv("ORANGE_CONF")
        print(string.char(27) .. "[34m" .. "[INFO]" .. string.char(27).. "[0m", [[the env[ORANGE_CONF] is ]], env_orange_conf)

        -- Here, you can also use the absolute path, eg: local confige_file = "/home/openresty/orange/conf/orange.conf"
        local config_file = env_orange_conf or ngx.config.prefix().. "/conf/orange.conf"
        local config, store = orange.init({
            config = config_file
        })

        -- the orange context
        context = {
            orange = orange,
            store = store,
            config = config
        }
    }

    init_worker_by_lua_block {
        local orange = context.orange
        orange.init_worker()
    }

    # main server
    server {
        listen       80;
        #server_name  my_domain.com;

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location / {
            set $upstream_host $host;
            set $upstream_url 'http://default_upstream';

            rewrite_by_lua_block {
                local orange = context.orange
                orange.redirect()
                orange.rewrite()
            }

            access_by_lua_block {
                local orange = context.orange
                orange.access()
            }

            # proxy
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_set_header Host $upstream_host;
            proxy_pass $upstream_url;


            header_filter_by_lua_block {
                local orange = context.orange
                orange.header_filter()
            }

            body_filter_by_lua_block {
                local orange = context.orange
                orange.body_filter()
            }

            log_by_lua_block {
                local orange = context.orange
                orange.log()
            }
        }

        location /robots.txt {
            return 200 'User-agent: *\nDisallow: /';
        }
    }

    # default upstream server
    server {
        listen 8001;
        server_name localhost 127.0.0.1;
        access_log ./logs/default_upstream_access.log main;
        error_log ./logs/default_upstream_error.log;

        location / {
            content_by_lua_block {
                local json = require "cjson"
                ngx.status = 200
                ngx.say("Host: "..ngx.var.host .. "  URI: " .. ngx.var.uri)
                ngx.say('[Query Params]', json.encode(ngx.req.get_uri_args()))
                ngx.req.read_body()
                ngx.say('[Post Params]', json.encode(ngx.req.get_post_args()))
                ngx.say('[Header Params]', json.encode(ngx.req.get_headers()))
            }
        }
    }


    # orange dashboard server
    server {
        listen       9999;
        stub_status on;
        #server_name  localhost;
        access_log ./logs/dashboard_access.log main;
        error_log ./logs/dashboard_error.log info;

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location /robots.txt {
            return 200 'User-agent: *\nDisallow: /';
        }

        # dashboard的静态文件
        location ~* /static/(.*) {
            alias ./dashboard/static/$1;
        }

        location / {
            set $template_root '';
            content_by_lua_block {
                context.views_path = ngx.config.prefix() .. "/dashboard/views"
                local main = require("dashboard.main")
                main:run()
            }
        }
    }

    # api server
    server {
        listen       7777;
        #server_name  localhost;
        access_log ./logs/api_access.log main;
        error_log ./logs/api_error.log info;

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location /robots.txt {
            return 200 'User-agent: *\nDisallow: /';
        }

        location / {
            content_by_lua_block {
                local main = require("api.main")
                main:run()
            }
        }
    }
  #    ----------------------------这里-----------------************ 
    server {
        listen 443 ssl;
        server_name *.baidu.com;
        ssl_certificate /xxxx;
        ssl_certificate_key /xxxx;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;

        location / {
            root /xxxx;
            try_files $uri /index.html;
        }
    }

}

@769344359
Copy link
Contributor

769344359 commented Jan 15, 2020

你可以仿照80端口的server代码块配置 @boot-vue,443里面缺了很多lua代码的回调

当然你也可以本地curl 127.0.0.1 看看80端口的效果

@boot-vue
Copy link
Author

你可以仿照80端口的server代码块配置 @boot-vue,443里面缺了很多lua代码的回调

当然你也可以本地curl 127.0.0.1 看看80端口的效果

是 没仔细看 我以为原有的配置都是给orange用的 原来如此 thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants