How to route to an endpoint protected with basic authentication? Error: there was a problem proxying the request

Would like to route to an target url protected with basic auth.
Have read some FAQ regarding to use “strip_auth_data”: false but still failed.
The error “There was a problem proxying the request” appears.
Please find my API json as below:

“name”:“es-h06gpu”,
“api_id”:“1”,
“org_id”:“4”,
“auth”: {},
“use_keyless”: true,
“version_data”: {
“not_versioned”: true,
“versions”: {
“Default”: {
“name”: “Default”,
“use_extended_paths”: true
}
}
},
“proxy”:{
“listen_path”:“/es-h06gpu”,
“target_url”:“https://mykibana.its.polyu.edu.hk:21013/h06-gpu-card-usage-filebeat-logstash”,
“strip_listen_path”:true
},
“active”:true,
“strip_auth_data”: false
}

Any idea how to route to an endpoint protected with basic authentication?
Thanks.

Hi @NgariNdungu and welcome to the community.

If my memory serves me right, a basic auth can also be written as

Basic base64Encode(username:password)

So if you have a username: [email protected] and a password: password, your base64 encoded value should be

Authorization: Basic am9obi5kb2VAdHlrLmlvOnBhc3N3b3Jk

Let us know if that works.

Hi Olu, I have tried both the “strip_auth_data”: false or the global header Basic base64Encode(username:password), but both are not worked.
I then searched through the internet and checked my target url and found that it is actually using a self signed cert. and seems it will cause problem.

I will try the workaround as mentioned in the above link or do u have further knowledge on this issue?
Thanks.

Finally get through it. Have to make changes to below bold types in API JSON. Thanks.

{
“name”:“es-h06gpu”,
“api_id”:“1”,
“org_id”:“4”,
“use_keyless”: true,
“version_data”: {
“not_versioned”: true,
“versions”: {
“Default”: {
“name”: “Default”,
“use_extended_paths”: true
}
}
},
“proxy”:{
“listen_path”:“/es-h06gpu”,
“target_url”:“https://mykibana.its.polyu.edu.hk:21013/h06-gpu-card-usage-filebeat-logstash”,
“strip_listen_path”:true,
“transport”: {
“ssl_insecure_skip_verify”: true
}

},
“active”:true,
“strip_auth_data”: false
}