nginx.conf 2.1 KB
Newer Older
1 2 3 4 5 6
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

worker_processes  1;
daemon off;
error_log /dev/stdout error;

events {
    worker_connections 1024;
}
23

24
http {
25
    resolver local=on ipv6=off;
26 27 28 29 30 31 32 33 34 35
    lua_package_path "/usr/share/skywalking-nginx-lua/lib/skywalking/?.lua;;";
    # Buffer represents the register inform and the queue of the finished segment
    lua_shared_dict tracing_buffer 100m;

    # Init is the timer setter and keeper
    # Setup an infinite loop timer to do register and trace report.
    init_worker_by_lua_block {
        local metadata_buffer = ngx.shared.tracing_buffer

        metadata_buffer:set('serviceName', 'User_Service_Name')
36
        -- Instance means the number of Nginx deployment, does not mean the worker instances
37 38
        metadata_buffer:set('serviceInstanceName', 'User_Service_Instance_Name')

39
        require("client"):startBackendTimer("http://oap:12800")
40
    }
41

42 43 44 45 46
    log_format sw_trace escape=json "$uri $request_body";

    server {
        listen 8080;

47
        location /nginx/info {
48 49 50 51 52

            rewrite_by_lua_block {
                require("tracer"):start("User_Service_Name")
            }

53
            proxy_pass http://provider-end:9090/info;
54 55 56 57 58 59 60 61 62 63

            body_filter_by_lua_block {
                require("tracer"):finish()
            }

            log_by_lua_block {
                require("tracer"):prepareForReport()
            }
        }
    }
64
}