Log browser inconsistencies

We have an API that is versioned, which basically switches the upstream provider by looking at the header value target

An example request:

 curl -v -H "target: customer" http://tyk.api.com:8080/api/v2/customer
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to tyk.api.com (127.0.0.1) port 8080 (#0)
> GET /api/v2/customer HTTP/1.1
> Host: tyk.api.com:8080
> User-Agent: curl/7.54.0
> Accept: */*
> target: customer
>
// snip, reply from httpbin
<

Gateway debug log.

gateway_1    | time="Mar  1 15:40:58" level=debug msg="Started proxy"
gateway_1    | time="Mar  1 15:40:58" level=debug msg="Stripping: /"
gateway_1    | time="Mar  1 15:40:58" level=debug msg="Upstream Path is: api/v2/customer"
gateway_1    | time="Mar  1 15:40:58" level=debug msg="Serving Multi-target..."
gateway_1    | time="Mar  1 15:40:58" level=debug msg="UPSTREAM REQUEST URL: api/v2/customer"
gateway_1    | time="Mar  1 15:40:58" level=debug msg="Outbound Request: http://customer-api:4000/api/v2/customer"

However the Log browser is showing the request as /apiv2/customer instead of /api/v2/customer

Similarly, mongo is showing the same thing in the data store.

I see, definitely some sort of bug in analytics pipeline. How you match this URL in API designer, do you have “/” in at the beginning of the match?

Thank you.

I am using a Custom Domain which is set to tyk.api.com, listen path set to / and Strip the listen path is checked

So I can get the top level domain to route my APIs.

Then I am using API versioning, which listens to the target header.

Which allows me to make this request: curl -v -H "target: customer" http://tyk.api.com:8080/api/v2/customer

Let me know if this makes sense, happy to share the entire API def json if needed.

Edit
39 AM

It seems like only the first segment is having the problem. Since the rest of the slashes are kept.

Thank you!

We trying to replicate this bug with data your provided, and will let you know.

@billxinli Could you please share your api definition and tyk.conf file here?

tyk.conf

{
  "log_level": "debug",
  "listen_port": 8080,
  "secret": "gateway-secret",
  "node_secret": "node-secret",
  "template_path": "/opt/tyk-gateway/templates",
  "tyk_js_path": "/opt/tyk-gateway/js/tyk.js",
  "middleware_path": "/opt/tyk-gateway/middleware",
  "use_db_app_configs": true,
  "db_app_conf_options": {
    "connection_string": "http://dashboard:3000",
    "node_is_segmented": false,
    "tags": [
      "test2"
    ]
  },
  "disable_dashboard_zeroconf": false,
  "app_path": "/opt/tyk-gateway/apps",
  "storage": {
    "type": "redis",
    "host": "redis",
    "port": 6379,
    "username": "",
    "password": "",
    "database": 0,
    "optimisation_max_idle": 100,
    "optimisation_max_active": 4000
  },
  "enable_analytics": true,
  "analytics_config": {
    "type": "mongo",
    "pool_size": 100,
    "csv_dir": "/tmp",
    "mongo_url": "",
    "mongo_db_name": "",
    "mongo_collection": "",
    "purge_delay": -1,
    "ignored_ips": [],
    "enable_detailed_recording": true,
    "enable_geo_ip": false,
    "geo_ip_db_path": "",
    "normalise_urls": {
      "enabled": true,
      "normalise_uuids": true,
      "normalise_numbers": true,
      "custom_patterns": []
    }
  },
  "health_check": {
    "enable_health_checks": true,
    "health_check_value_timeouts": 60
  },
  "optimisations_use_async_session_write": true,
  "allow_master_keys": false,
  "policies": {
    "policy_source": "service",
    "policy_connection_string": "http://dashboard:3000",
    "policy_record_name": "tyk_policies",
    "allow_explicit_policy_id": true
  },
  "hash_keys": false,
  "suppress_redis_signal_reload": false,
  "use_redis_log": true,
  "close_connections": true,
  "enable_non_transactional_rate_limiter": true,
  "enable_sentinel_rate_limiter": false,
  "experimental_process_org_off_thread": true,
  "local_session_cache": {
    "disable_cached_session_state": false
  },
  "http_server_options": {
    "enable_websockets": true
  },
  "uptime_tests": {
    "disable": false,
    "config": {
      "enable_uptime_analytics": true,
      "failure_trigger_sample_size": 2,
      "time_wait": 10,
      "checker_pool_size": 50
    }
  },
  "hostname": "",
  "enable_custom_domains": true,
  "enable_jsvm": true,
  "oauth_redirect_uri_separator": ";",
  "coprocess_options": {
    "enable_coprocess": true,
    "coprocess_grpc_server": "tcp://grpc:5555"
  },
  "pid_file_location": "./tyk-gateway.pid",
  "allow_insecure_configs": true,
  "public_key_path": "",
  "close_idle_connections": false,
  "allow_remote_config": false,
  "enable_bundle_downloader": true,
  "bundle_base_url": "http://grpc:8888/",
  "global_session_lifetime": 100,
  "force_global_session_lifetime": false,
  "max_idle_connections_per_host": 100
}

So I am using the restful API to create my API. And this is what I am POSTing to the end point:

  "api_definition": {
    "custom_middleware_bundle": "token-check.zip",
    "use_keyless": false,
    "enable_coprocess_auth": true,
    "use_oauth2": false,
    "use_openid": false,
    "auth": {
      "use_param": false,
      "param_name": "",
      "use_cookie": false,
      "cookie_name": "",
      "auth_header_name": "",
      "use_certificate": false
    },
    "domain": "gateway.tyk.api.com",
    "proxy": {
      "listen_path": "/",
      "target_url": "https://backend.api.com/"
    },
    "definition": {
      "location": "header",
      "key": "target"
    },
    "version_data": {
      "not_versioned": false,
      "default_version": "login",
      "versions": {
        "login": {
          "name": "login",
          "expires": "",
          "paths": {
            "ignored": [],
            "white_list": [],
            "black_list": []
          },
          "use_extended_paths": true,
          "extended_paths": {
            "url_rewrites": [
              {
                "path": "sdf",
                "method": "GET",
                "match_pattern": "sdf/(.*)",
                "rewrite_to": "http://httpbin.org/anything/sdf/$1",
                "triggers": []
              }
            ]
          },
          "global_headers": {},
          "global_headers_remove": [
            "authorization"
          ],
          "global_size_limit": 0,
          "override_target": "http://httpbin.org/anything/proxy"
        },
        "customer": {
          "name": "customer",
          "override_target": "http://customer:4000",
          "expires": "",
          "paths": {
            "ignored": [],
            "white_list": [],
            "black_list": []
          },
          "use_extended_paths": true,
          "extended_paths": {},
          "global_headers": {},
          "global_headers_remove": [],
          "global_size_limit": 0
        },
        "usage": {
          "name": "usage",
          "override_target": "http://usage:4000",
          "expires": "",
          "paths": {
            "ignored": [],
            "white_list": [],
            "black_list": []
          },
          "use_extended_paths": true,
          "extended_paths": {},
          "global_headers": {},
          "global_headers_remove": [],
          "global_size_limit": 0
        }
        /// snip.. similar to usage and customer
      }
    }
  }
}