Google Cloud Platform 上的 Bitnami 启用 SSL 问题:启用 SSL 时请修复 DNS 条目

Bitnami on Google Cloud Platform enabling SSL Issue: Please fix DNS entries while enabling SSL

我在 Google 云平台堆栈上使用 bitnami django。

目标:我希望在 Google 云上托管的 bitnami 堆栈上配置 SSL。但是他们的 toolsudo ./bncert-tool 抱怨“该域解析为与本机检测到的 IP 地址不同的 IP 地址。请修复其 DNS 条目或将其删除。

我购买了一个使用 google 个域的域。

我已将 google dns 设置为指向我在 bitnami 堆栈中看到的 IP 地址。我在Google域名设置

中启用了mydomain.com和www.mydomain.com转发到云服务器ipaddress/home

然后我尝试 运行 工具 /opt/bitnami/bncert-tool:

sudo /opt/bitnami/bncert-tool


Welcome to the Bitnami HTTPS Configuration tool.

Domains

Please provide a valid space-separated list of domains for which you wish to
configure your web server.

Domain list []: mydomain.com

The following domains were not included: www.mydomain.com. Do you want to add them? [Y/n]: n

Warning: No www domains (e.g. www.example.com) or non-www domains (e.g.
www.example.com) have been provided, so the following redirections will be
disabled: non-www to www, www to non-www.
Press [Enter] to continue:
Warning: The domain 'mydomain.com' resolves to a different IP address than the
one detected for this machine, which is 'aa.bb.ccc.dddd'. Please fix its DNS
entries or remove it. For more info see:
https://docs.bitnami.com/general/faq/configuration/configure-custom-domain/
Press [Enter] to continue:

我的问题: 我该如何解决这个问题?我什至尝试添加两个域 mydomain.comwww.mydomain.com

我想为 mydomain.com 和 www.mydomain.com 启用 SSL,但不确定哪里出错了?

其次,link转发后,如何关联我的域名,让静态IP不一直显示,而是显示映射域mydomain。com/home

谢谢 肥皂水

$nslookup mydomain
Server:     192.168.0.1
Address:    192.168.0.1#53

Non-authoritative answer:
Name:   mydomain.com
Address: 216.239.32.21
Name:   mydomain.com
Address: 216.239.34.21
Name:   mydomain.com
Address: 216.239.36.21
Name:   mydomain.com
Address: 216.239.38.21
$ nslookup www.mydomain.com
Server:     192.168.0.1
Address:    192.168.0.1#53

Non-authoritative answer:
www.mydomain.com    canonical name = ghs.googlehosted.com.
Name:   ghs.googlehosted.com
Address: 172.217.26.179


$ dig +short NS mydomain.com ns-cloud-b1.googledomains.com.
ns-cloud-b2.googledomains.com. ns-cloud-b3.googledomains.com.
ns-cloud-b4.googledomains.com.

$ dig +short NS www.mydomain.com ghs.googlehosted.com.

您可能需要更改某些设置,例如域名设置。如果使用 Google 域,转发实际上不会将 A + Cname 集成到一个静态 IP。我必须实际创建 A 和 CName 记录。

这解决了第一个问题:有趣的是我的一个域:mydomain.com 指向多个 IP 地址,而另一个指向不同的 IP,具体取决于 DNS 服务器。这也是导致我以前得到的错误的原因

when I ran sudo ./bncert-tool "The domain 'mydomain.com' resolves to a different IP address than the one detected for this machine, which is 'aa.bb.ccc.ddd'. Please fix its DNS entries or remove it. 

我认为在网络服务器设置中物理强制了 HTTPS 重定向。使用此规则

/opt/bitnami/apache2/conf/bitnami/bitnami.conf,

Changed  RewriteRule ^/(.*) https://example.com/ [R,L]

然后我仍然遇到一些问题,第一次点击 URL 将加载,下一次点击我会出现 404 错误。

我意识到这是项目级别设置的问题

opt/bitnami/apps/django/django_projects/Project/conf

sudo vi httpd-app.conf

WSGIScriptAlias /PROJECT '/opt/bitnami/apps/django/django_projects/PROJECT/PROJECT/wsgi.py'

to

WSGIScriptAlias / '/opt/bitnami/apps/django/django_projects/myproject/myproject/wsgi.py'

然后是 settings.py 中允许的主机的问题: 确保更新了正确的允许主机,项目根目录或您的应用程序根目录,具体取决于您提供服务的位置。 /opt/bitnami/apps/django/django_projects/Project/Project 在这里更新了py中的设置... ALLOWED_HOSTS 在 settings.py