Proxy Change Post request to Get request

Post request to Tyk, and Tyk proxy request to an upstream server. However my upstream server
received Get request.

Here is the proxy setting from API definition:
“proxy”: {
“target_url”: “https://xxx.xxx.xxx/auth/”,
“service_discovery”: {
“endpoint_returns_list”: false,
“cache_timeout”: 0,
“parent_data_path”: “”,
“query_endpoint”: “”,
“use_discovery_service”: false,
“_sd_show_port_path”: false,
“target_path”: “”,
“use_target_list”: false,
“use_nested_query”: false,
“data_path”: “”,
“port_data_path”: “”
},
“check_host_against_uptime_tests”: false,
“transport”: {
“ssl_ciphers”: [],
“ssl_min_version”: 0,
“proxy_url”: “”
},
“target_list”: [],
“preserve_host_header”: false,
“strip_listen_path”: true,
“enable_load_balancing”: false,
“listen_path”: “/auth/”,
“disable_strip_slash”: false
},

However, if I change “target_url” to “https://xxx.xxx.xxx/”, “strip_listen_path” to false, “listen_path” to “/auth/”, my upstream server was able to receive Post request as expected.

I posted to my Tyk on-premises server via http://tyk.test.server/auth/ and with JSON request body.

PS:

  • NO method transform plugin is used.
  • Using Tyk dashboard v1.7.6 and Tyk gateway v2.7.7.
  • Authentication is set to Open(Keyless).

Does anyone have similar issues or know how to solve this? Thank you guys.

Hi,

I am not able to reproduce the issue.
Can you share your entire API definition file?
Can you also send logs of gateway when endpoint is requested?

Thanks
Komal

Hello Komal,
Here is my API definition:
{
“api_model”: {},
“api_definition”: {
“api_id”: “ece00e724a884cd3782554741322e33c”,
“jwt_issued_at_validation_skew”: 0,
“upstream_certificates”: {},
“use_keyless”: true,
“enable_coprocess_auth”: false,
“custom_middleware”: {
“pre”: [],
“post”: [],
“post_key_auth”: [],
“auth_check”: {
“name”: “”,
“path”: “”,
“require_session”: false
},
“response”: [],
“driver”: “”,
“id_extractor”: {
“extract_from”: “”,
“extract_with”: “”,
“extractor_config”: {}
}
},
“disable_quota”: false,
“custom_middleware_bundle”: “”,
“cache_options”: {
“cache_timeout”: 60,
“enable_cache”: true,
“cache_all_safe_requests”: false,
“cache_response_codes”: [],
“enable_upstream_cache_control”: false,
“cache_control_ttl_header”: “”
},
“enable_ip_blacklisting”: false,
“tag_headers”: [],
“pinned_public_keys”: {},
“expire_analytics_after”: 0,
“domain”: “”,
“openid_options”: {
“providers”: [],
“segregate_by_client”: false
},
“active”: true,
“jwt_expires_at_validation_skew”: 0,
“config_data”: {},
“notifications”: {
“shared_secret”: “”,
“oauth_on_keychange_url”: “”
},
“auth”: {
“auth_header_name”: “Authorization”,
“signature”: {
“algorithm”: “”,
“header”: “”,
“secret”: “”,
“allowed_clock_skew”: 0,
“error_code”: 0,
“error_message”: “”
},
“validate_signature”: false,
“use_certificate”: false
},
“check_host_against_uptime_tests”: false,
“auth_provider”: {
“name”: “”,
“storage_engine”: “”,
“meta”: {}
},
“blacklisted_ips”: [],
“hmac_allowed_clock_skew”: -1,
“dont_set_quota_on_create”: false,
“uptime_tests”: {
“check_list”: [],
“config”: {
“expire_utime_after”: 0,
“service_discovery”: {
“use_discovery_service”: false,
“query_endpoint”: “”,
“use_nested_query”: false,
“parent_data_path”: “”,
“data_path”: “”,
“cache_timeout”: 60
},
“recheck_wait”: 0
}
},
“enable_jwt”: false,
“do_not_track”: false,
“name”: “auth”,
“slug”: “test”,
“oauth_meta”: {
“allowed_access_types”: [],
“allowed_authorize_types”: [],
“auth_login_redirect”: “”
},
“CORS”: {
“enable”: false,
“max_age”: 24,
“allow_credentials”: false,
“exposed_headers”: [],
“allowed_headers”: [],
“options_passthrough”: false,
“debug”: false,
“allowed_origins”: [],
“allowed_methods”: []
},
“event_handlers”: {
“events”: {}
},
“proxy”: {
“target_url”: “https://xxx.xxx.xxx/auth/”,
“service_discovery”: {
“endpoint_returns_list”: false,
“cache_timeout”: 0,
“parent_data_path”: “”,
“query_endpoint”: “”,
“use_discovery_service”: false,
“_sd_show_port_path”: false,
“target_path”: “”,
“use_target_list”: false,
“use_nested_query”: false,
“data_path”: “”,
“port_data_path”: “”
},
“check_host_against_uptime_tests”: false,
“transport”: {
“ssl_ciphers”: [],
“ssl_min_version”: 0,
“proxy_url”: “”
},
“target_list”: [],
“preserve_host_header”: false,
“strip_listen_path”: true,
“enable_load_balancing”: false,
“listen_path”: “/auth/”,
“disable_strip_slash”: false
},
“client_certificates”: [],
“use_basic_auth”: false,
“version_data”: {
“not_versioned”: true,
“default_version”: “”,
“versions”: {
“Default”: {
“name”: “Default”,
“expires”: “”,
“paths”: {
“ignored”: [],
“white_list”: [],
“black_list”: []
},
“use_extended_paths”: true,
“extended_paths”: {
“ignored”: [],
“white_list”: [],
“black_list”: [],
“transform”: [],
“transform_response”: [],
“transform_jq”: [],
“transform_jq_response”: [],
“transform_headers”: [],
“transform_response_headers”: [],
“hard_timeouts”: [],
“circuit_breakers”: [],
“url_rewrites”: [],
“virtual”: [],
“size_limits”: [],
“method_transforms”: [],
“track_endpoints”: [],
“do_not_track_endpoints”: [],
“validate_json”: []
},
“global_headers”: {},
“global_headers_remove”: [],
“global_size_limit”: 0,
“override_target”: “”
}
}
},
“use_standard_auth”: false,
“session_lifetime”: 0,
“hmac_allowed_algorithms”: [],
“disable_rate_limit”: false,
“definition”: {
“location”: “header”,
“key”: “x-api-version”,
“strip_path”: false
},
“use_oauth2”: false,
“jwt_not_before_validation_skew”: 0,
“allowed_ips”: [],
“org_id”: “5ca6a6125b7e08116816c7e4”,
“enable_ip_whitelisting”: false,
“global_rate_limit”: {
“rate”: 0,
“per”: 0
},
“enable_context_vars”: false,
“tags”: [],
“basic_auth”: {
“disable_caching”: false,
“cache_ttl”: 0,
“extract_from_body”: false,
“body_user_regexp”: “”,
“body_password_regexp”: “”
},
“session_provider”: {
“name”: “”,
“storage_engine”: “”,
“meta”: {}
},
“strip_auth_data”: false,
“id”: “5cb66ed15b7e08733b8334d0”,
“certificates”: [],
“enable_signature_checking”: false,
“use_openid”: false,
“jwt_skip_kid”: false,
“enable_batch_request_support”: false,
“response_processors”: [],
“use_mutual_tls_auth”: false
},
“hook_references”: [],
“is_site”: false,
“sort_by”: 0
}

Regarding the gateway log, I did not see any log generated when my POST requests poxy through Tyk.
Is there a verbose mode that I can turn on to get more log to investigate?

Thank you Komal

Did you ever find the answer to this? Im having the same issue currently.

Hi Kasper
I just tested the api above for httpbin and it worked for me (replaced “auth” with “anything”):

  "target_url": "http://httpbin.org/anything", 
  "listen_path": "/anything/",
  "strip_listen_path": true,

Here is the output:

====== Request ======
POST / HTTP/1.1

{"hi":"bye"}
====== Response ======
HTTP/1.1 200 OK
Content-Length: 417
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Fri, 22 Jan 2021 15:35:54 GMT
Server: gunicorn/19.9.0
X-Ratelimit-Limit: 0
X-Ratelimit-Remaining: 0
X-Ratelimit-Reset: 0

{
  "args": {}, 
  "data": "{\"hi\":\"bye\"}", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept-Encoding": "gzip", 
    "Content-Length": "12", 
    "Host": "httpbin.org", 
    "User-Agent": "Tyk/v3.0.1", 
    "X-Amzn-Trace-Id": "Root=1-600af0da-0ed6426c5d925b3834fe135a"
  }, 
  "json": {
    "hi": "bye"
  }, 
  "method": "POST", 
  "origin": ", 90.240.199.172", 
  "url": "http://httpbin.org/anything"
}

Can you please send us more details to demonstrate the issue? Also which version are you using?
Thanks
Yaara

1 Like

Hello Yaara
Unfortunately im just a consumer and not a developer on our companys Tyk setup, so I’m lacking some
insights into whats going on in the backend, but I’ve had a chat with our devs who suggested it could be due to bad syntax in my used URLs or double slashes, though I haven’t been able to identify any such cases.

For the information I DO have access to:

To me the Prod/Dev setup looks identical, so im thinking I need to request access or help to debug the Tyk Prod backend or it’s logs. But first, can you confirm I havent made any obvious mistake, before I escalate this issue internally?

Hi Kasper,
Sorry, I haven’t seen a notification of your reply. Can you please post the results again since I the links are no longer available.
THanks

BTW, to turn on debug you can set

“enable_detailed_recording”: true,

in the api definition.

Which release are we talking about?
and last thing - can you please send me the response you get in both envs?
curl -X POST https://tyk-gateway.localhost:8081/post-to-get/anything/1 -I