简体   繁体   English

Google Cloud App Engine:如何在灵活的环境中提供https

[英]Google Cloud App Engine: How to serve https in a Flexible environment

I work on a python3.6 app that uses flask and oauth2client. 我在使用flask和oauth2client的python3.6应用程序上工作。

I want to serve https instead of http in gcloud environment. 我想在gcloud环境中提供https而不是http。

I tried using talisman-flask: 我尝试使用护符瓶:

https://github.com/GoogleCloudPlatform/flask-talisman https://github.com/GoogleCloudPlatform/flask-talisman

However, when I ran their sample app locally I got this error in my browser: 但是,当我在本地运行他们的示例应用程序时,我的浏览器出现此错误:

This site can't provide a secure connection 该网站无法提供安全的连接
127.0.0.1 sent an invalid response. 127.0.0.1发送了无效的响应。

It works fine for http, but can't apparently serve https. 它适用于http,但显然不能提供https。

Are there some Talisman configurations I need to change? 我需要更改一些护身符配置吗?
Or maybe a whole different solution altogheter? 还是一个完全不同的解决方案?

EDIT: 编辑:

I changed from debug=True to debug=False and now I get automatically redirected to https but the above error message is still there. 我从debug=True更改为debug=False ,现在我自动重定向到https,但是上面的错误消息仍然存在。

One rather generic approach which can work even with the standard environment local development server (which doesn't support HTTPS) would be to use a reverse proxy. 即使使用标准环境本地开发服务器(不支持HTTPS)也可以使用的一种相当通用的方法是使用反向代理。

Such solutions are documented in Appengine - Local dev server with https 此类解决方案记录在Appengine-带有https的本地开发服务器中

It's an old thread, but if you want to serve HTTPS (with or without Talisman) you need, at least, a valid certificate. 这是一个旧线程,但是如果要提供HTTPS(带有或不带有Talisman),则至少需要一个有效的证书。 Please, create one at Let's Encrypt and install in your web server, even if your site are in the web or in your local environment. 请在“加密”中创建一个,然后将其安装在Web服务器中,即使您的站点在Web本地环境中也是如此。 If you want a good tutorial to help further, I recommend this from Miguel Grinberg, a big "Flask Guru" ;-) . 如果你想要一个很好的教程,以进一步帮助,我建议这个米格尔格林贝格,一个大大的“瓶宗师” ;-)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM