0

I got my Dropwizard application running in an Openshift DIY Cartridge.

The application uses Https and binds to port 8080. I can access the application with curl from within an ssh connection via rhc ssh appname.

What do I have do configure that I can access my Dropwizard application via the appname-username.rhcloud.com domain?

I always get a proxy error 502. Error reading from remote server.

Any suggestion is greatly appreciated.

tmy

timo.rieber
  • 3,727
  • 3
  • 32
  • 47
tmy
  • 25
  • 4

1 Answers1

1

In OpenShift your application is deployed behind a proxy server ant this proxy server can only communicate with your application using http.

The OpenShift proxy server allows you to use both http and https connections and to communicate which type of connection was used the proxy server adds x-forwarded headers in the request to your application.

Tho configure Dropwizard, you will need to configure the http connector on port 8080, the default, and set useForwardedHeaders to true, also the default. See http://dropwizard.io/manual/configuration.html#http for more information.

At this point Dropwizard is aware whether a http or https connection was used. The thing I did not find is how to make content "confidential" so that the jetty container inside Dropwizard redirect the client to the https connector served by the OpenShift proxy server when the client tries to connect to your application using http.

MartinB
  • 231
  • 1
  • 5
  • I got it working and now I'm trying to redirect Http access to Https using this description: https://help.openshift.com/hc/en-us/articles/202398810-How-to-redirect-traffic-to-HTTPS- I edit this comment if I have more information. – tmy Dec 14 '14 at 18:12
  • 1
    The general solution is to write a servlet filter which checks to see if the request is secure (ServletRequest#isSecure()) and redirect to the same URI on HTTPS if it's not. – MartinB Dec 14 '14 at 21:21