Skullabs / kikaha

A fast middleware designed for microservices
https://skullabs.github.io/kikaha/
Apache License 2.0
59 stars 13 forks source link

Reverse proxy does not support SSL endpoints #246

Closed Ibratan closed 6 years ago

Ibratan commented 6 years ago

Hi @miere

It seems that the reverse proxy feature does not support SSL routes. Taking a deep look into the source code we've noticed that the ReverseProxyClientProvider class is based on the Undertow's SimpleProxyClientProvider, which does not properly supports SSL routes. I think that this is just a matter of providing a SSLContext to the client, but I didn't had enough time to finish a patch.

I'll give it a try this weekend and I'll PR you back! ;)

roneigebert commented 6 years ago

Reverse proxy not works with host app.capacitor.digitar over HTTPS protocol.

My configuration file:

server:
  http: { port: 9009 }
  static: { enabled: true }
  smart-routes:
    reverse:
      - { path: "/api/{path}", to: "https://app.capacitor.digital/api/{path}" }

When access http://localhost:9009/api/parameters or http://localhost:9009/api/me:

10:33:55.991 UT005028: Proxy request to https://app.capacitor.digital/api/parameters failed
java.io.IOException: UT000103: Http2 stream was reset
        at io.undertow.client.http2.Http2ClientConnection$Http2ReceiveListener.handleEvent(Http2ClientConnection.java:400)
        at io.undertow.client.http2.Http2ClientConnection$Http2ReceiveListener.handleEvent(Http2ClientConnection.java:347)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:932)
        at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:913)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener$1.run(AbstractFramedChannel.java:939)
        at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:919)
        at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:913)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
        at io.undertow.protocols.ssl.SslConduit$SslReadReadyHandler.readReady(SslConduit.java:1129)
        at io.undertow.protocols.ssl.SslConduit$1.run(SslConduit.java:168)
        at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:580)
        at org.xnio.nio.WorkerThread.run(WorkerThread.java:464)
10:34:34.52 UT005028: Proxy request to https://app.capacitor.digital/api/me failed
java.io.IOException: UT000103: Http2 stream was reset
        at io.undertow.client.http2.Http2ClientConnection$Http2ReceiveListener.handleEvent(Http2ClientConnection.java:400)
        at io.undertow.client.http2.Http2ClientConnection$Http2ReceiveListener.handleEvent(Http2ClientConnection.java:347)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:932)
        at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:913)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
        at io.undertow.protocols.ssl.SslConduit$SslReadReadyHandler.readReady(SslConduit.java:1129)
        at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88)
        at org.xnio.nio.WorkerThread.run(WorkerThread.java:559)
miere commented 6 years ago

@roneigebert thanks for your feedback, brow! I'll give a closer look on it tonight.