How to fix google cloud ssl issue

喜夏-厌秋 提交于 2020-01-03 04:48:13

问题


I pointed a new custom domain to a Google App Engine Standard Environment project and edited the DNS records per Google's instructions, and it seems to be redirected properly.

When I go to

www.mydomain.com 

with its supposedly activated certificate, I still get

connection is not secure

in the browser. If I go to

mydomain.com 

it gets redirected to

www.mydomain.com 

with the same result.

But when I directly enter

https ://www.mydomain.com

it display the website and with connection is secure. Let me know the reason for this and how to fix this issue?

I used below command

gcloud app domain-mappings list 

and it displays that there is a ssl certificate id. But the above issue is still there.


回答1:


The answer to this question depends on which language and which environment you're using.

Node.js and flexible environment

It looks like you are using Node.js, in the case of Node.js for both standard and flexible environments, and for flexible environment users of all languages, you need to handle the redirect in your application's code. How you do this might change depending on if you're using a Framework. Check out the answer for how to do this with an Express app as an example.

First generation standard environment

For the standard environment Python 2.7, PHP 5.5, and Go 1.9, you need to instruct App Engine to always use the secure connection for requests by updating your app.yaml configuration file's handlers to look something like:

handlers:
- url: /.* 
  script: main.app  # <- Python example
  secure: always
  redirect_http_response_code: 301


来源:https://stackoverflow.com/questions/54148472/how-to-fix-google-cloud-ssl-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!