Skip to content Skip to sidebar Skip to footer

How To Add A Ssl Certificate To A Dash App

How can I enable HTTPS for a DASH aplication running on a webserver with Python? I already have a SSL certificate (.key and .crt)

Solution 1:

If dash is the web server handling the routing (instead of Apache or Nginx), in your index.py file, on the part where you initiate the server, put the following code (replace local.crt and local.key with the absolute or relative path of your certificates):

if__name__== "__main__":
    context = ('local.crt','local.key')
    app.run_server(host="192.168.200.172", port="8050", debug=True, ssl_context=context)

The address and the port is whatever you have on your server

or with the run method

app.run(debug=True, ssl_context=context)

If, Nginx or apache is handling the reverse proxy, meaning, it receives the request from the client and then directs it to different apps, Dash for example, then you need to configure the SSL certificate in that server, and then it will redirect a http petition to the Dash, but it will be shown to the user as a Https.

Post a Comment for "How To Add A Ssl Certificate To A Dash App"