# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; load_module /usr/lib/nginx/modules/ngx_http_opentracing_module.so; events { worker_connections 1024; } http { log_format json_custom escape=json '{' '"body_bytes_sent":$body_bytes_sent,' '"bytes_sent":$bytes_sent,' '"datetime":"$time_iso8601",' '"duration":$request_time,' '"extra.full_url":"$scheme://$host$request_uri",' '"extra.is_args":"$is_args",' '"extra.method":"$request_method",' '"extra.path":"$uri",' '"extra.query_string":"$query_string",' '"extra.referer":"$http_referer",' '"extra.remote_host":"$remote_addr",' '"extra.request":"$request",' '"extra.scheme":"$scheme",' '"extra.status_code":"$status",' '"extra.uri":"$request_uri",' '"extra.url":"$scheme://$host$uri",' '"extra.useragent":"$http_user_agent",' '"message":"$request_method $request_uri",' '"nginx_version":"$nginx_version",' '"pid":"$pid",' '"request_id":"$request_id",' '"response_content_type":"$sent_http_content_type",' '"time_local":"$time_local",' '"X-Forwarded-For":"$proxy_add_x_forwarded_for"' '}'; # Datadog tracing opentracing on; # Enable OpenTracing opentracing_tag http_user_agent $http_user_agent; # Add a tag to each trace! opentracing_trace_locations off; # Emit only one span per request. # Load the Datadog tracing implementation, and the given config file. opentracing_load_tracer /usr/local/lib/libdd_opentracing_plugin.so /etc/nginx/dd-config.json; access_log ${ACCESS_LOG_STATUS}; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; gzip on; gzip_comp_level 4; gzip_min_length 500; gzip_proxied any; gzip_types text/plain application/xml application/json text/json; proxy_cache_path ${PROXY_CACHE_PATH} levels=1:2 keys_zone=${PROXY_CACHE_KEYS_ZONE}:10m max_size=${PROXY_CACHE_MAX_SIZE} inactive=${PROXY_CACHE_INACTIVE} use_temp_path=off; proxy_buffer_size ${PROXY_BUFFER_SIZE}; proxy_buffers ${PROXY_BUFFERS}; proxy_busy_buffers_size ${PROXY_BUSY_BUFFERS_SIZE}; server { listen 80 default; server_name ${SERVER_NAME}; location /nginx_health { return 200 'test ok'; add_header Content-Type text/plain; } location ${HEALTHCHECK_PATH} { proxy_pass https://${BACKEND_ADDRESS}; } location ${DATACOMPLETENESS_PATH} { if ($http_authorization = false) { return 403; } proxy_pass https://${BACKEND_ADDRESS}; } location ${ADS_PERFOMANCE_ENDPOINT} { if ($http_authorization = false) { return 403; } proxy_cache ${PROXY_CACHE_KEYS_ZONE}; proxy_cache_bypass $http_pragma $cookie_nocache $arg_nocache; proxy_cache_methods GET; # Removed http authorization from the key, need to implement jwt verification #proxy_cache_key "$http_authorization$request_uri$is_args$args"; proxy_cache_key "$request_uri$is_args$args"; proxy_ignore_headers Cache-Control Expires Vary; proxy_cache_valid 200 ${ADS_PERFOMANCE_CACHE_INACTIVE}; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; proxy_cache_lock on; proxy_cache_lock_age 10s; add_header X-Cache-Status $upstream_cache_status; proxy_pass https://${BACKEND_ADDRESS}; opentracing_operation_name "$request_method $uri"; opentracing_propagate_context; } location ${TRACK_POSITIONS_CHARTS_ENDPOINT} { if ($http_authorization = false) { return 403; } proxy_cache ${PROXY_CACHE_KEYS_ZONE}; proxy_cache_bypass $http_pragma $cookie_nocache $arg_nocache; proxy_cache_methods GET; # Removed http authorization from the key, need to implement jwt verification #proxy_cache_key "$http_authorization$request_uri$is_args$args"; proxy_cache_key "$request_uri$is_args$args"; proxy_ignore_headers Cache-Control Expires Vary; proxy_cache_valid 200 ${TRACK_POSITIONS_CHARTS_CACHE_INACTIVE}; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; proxy_cache_lock on; proxy_cache_lock_age 10s; add_header X-Cache-Status $upstream_cache_status; proxy_pass https://${BACKEND_ADDRESS}; opentracing_operation_name "$request_method $uri"; opentracing_propagate_context; } location / { if ($http_authorization = false) { return 403; } proxy_cache ${PROXY_CACHE_KEYS_ZONE}; proxy_cache_bypass $http_pragma $cookie_nocache $arg_nocache; proxy_cache_methods GET; # Removed http authorization from the key, need to implement jwt verification #proxy_cache_key "$http_authorization$request_uri$is_args$args"; proxy_cache_key "$request_uri$is_args$args"; proxy_ignore_headers Cache-Control Expires Vary; proxy_cache_valid 200 ${PROXY_CACHE_INACTIVE}; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; proxy_cache_lock on; proxy_cache_lock_age 10s; add_header X-Cache-Status $upstream_cache_status; proxy_pass https://${BACKEND_ADDRESS}; opentracing_operation_name "$request_method $uri"; opentracing_propagate_context; } } }