Protocol not supported error on plugin redirecting to HTTPS target

Hello All,

I have a plugin that overrides the target URL for one set in the plugin configuration.

On this plugin, i'm changing the req.targetHostname and req.targetPath and, if the target protocol is https, i'm also changing the req.targetSecure to true and the req.targetPort to 443

req.targetHostname = targetPathHostname # new target hostname
req.targetPath = targetPath # new target path

if (targetPathProtocol === 'https') {
  req.targetSecure = true
  req.targetPort = 443
} 

With this, when the request is executed, i'm getting the following error:

curl -i http://localhost:8000/health
HTTP/1.1 500 Internal Server Error
Date: Wed, 24 May 2017 12:57:14 GMT
Connection: keep-alive
Content-Length: 67

{"message":"Protocol \"https:\" not supported. Expected \"http:\""}

Just to be sure, i've configured my edgemicro instance to work with ssl but the error was the same:

curl -i https://localhost:8000/health
HTTP/1.1 500 Internal Server Error
Date: Wed, 24 May 2017 12:57:14 GMT
Connection: keep-alive
Content-Length: 67

{"message":"Protocol \"https:\" not supported. Expected \"http:\""}

Is it possible to do this? Change the target URL and also change from HTTP to HTTPS?

I'm using the following versions:

<code>current nodejs version is v6.10.0
current edgemicro version is 2.4.5-beta
Solved Solved
0 3 1,021
2 ACCEPTED SOLUTIONS

Former Community Member
Not applicable
@Victor Anaylton Pinheiro de Castro Lopes

Microgateway uses a https agent when connecting to a target server that requires https. In addition to setting the flag targetSecure to true, you also need to pass the agent object.

Adding @Matthew Dobson

View solution in original post

Not applicable
3 REPLIES 3

Former Community Member
Not applicable
@Victor Anaylton Pinheiro de Castro Lopes

Microgateway uses a https agent when connecting to a target server that requires https. In addition to setting the flag targetSecure to true, you also need to pass the agent object.

Adding @Matthew Dobson

@Srinandan Sridhar Thanks for the anwser!

Matthew answered me yesterday on a github issue with an approach to solve this problem

https://github.com/apigee/microgateway-core/issues/81


I'll accept this answer and close this thread.

Thanks!

Not applicable