Skip to content

Instantly share code, notes, and snippets.

@sferich888
Last active August 29, 2015 14:00
Show Gist options
  • Save sferich888/11187493 to your computer and use it in GitHub Desktop.
Save sferich888/11187493 to your computer and use it in GitHub Desktop.
This can be used to ensure that the client using your application connected to OpenShift's SSL port prior to getting routed to your application.
@app.route('/endpoint')
def endpoint():
# Check for SSL on OpenShift, that is used to force SSL for your endpoint.
## You have to check for the X-Forwarded-Proto because of the OpenShift Node Router terminating the SSL.
if request.headers.get('X-Forwarded-Proto', 'http') != 'https':
return redirect(request.url.replace("http://", "https://"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment