如何将SSL证书添加到Dash应用程序 [英] How to Add a SSL certificate to a Dash App

查看:74
本文介绍了如何将SSL证书添加到Dash应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为使用Python在网络服务器上运行的DASH应用启用HTTPS?

How can I enable HTTPS for a DASH aplication running on a webserver with Python?

我已经有一个SSL证书(.key和.crt)

I already have a SSL certificate (.key and .crt)

推荐答案

如果破折号是处理路由的Web服务器(而不是Apache或Nginx),在您启动服务器的那部分的index.py文件中,放入以下代码(用证书的绝对或相对路径替换local.crt和local.key):

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

或使用run方法

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

如果Nginx或apache正在处理反向代理,这意味着它从客户端接收请求,然后将其定向到其他应用程序(例如Dash),那么您需要在该服务器中配置SSL证书,然后会将http请愿书重定向到Dash,但将以Https的形式显示给用户.

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.

这篇关于如何将SSL证书添加到Dash应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆