You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Cloud DNS域名跳转配置问题:HTTPS证书生成失败

Apache多域名托管与Certbot SSL证书生成失败排查

需求背景

我在Google Cloud Compute的Linux服务器上通过Apache托管多个网站,需要将*.com域名的所有流量(包括http://*.com/、http://www.*.com/、https://*.com/、https://www.*.com/)301跳转到主域名*.co,防止域名被仿冒。

已执行操作步骤

  1. 在服务器/var/www目录下创建*.co网站文件夹:
cd /var/www
ls
mkdir *.co
  1. 在/etc/apache2/sites-available目录下创建两个域名的配置文件:
  • *.co.conf配置:
<VirtualHost *:80>
    ServerAdmin _____@_____.com
    ServerName *.co
    ServerAlias www.*.co
    DocumentRoot /var/www/*.co
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  • *.com.conf配置(301跳转):
<VirtualHost *:80>
    ServerName *.com
    ServerAlias www.*.com
    Redirect 301 / http://*.co/
</VirtualHost>
  1. 启用配置并重启Apache:
sudo apache2ctl configtest
sudo a2ensite *.co.conf *.com.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
  1. 在Google Cloud DNS中为两个域名创建Zone,设置SOA、NS记录,并在Google Domains中配置对应自定义域名服务器,添加A记录指向服务器公网IP、CNAME记录使www指向主域名。

遇到的问题

当前HTTP站点正常运行,使用Ubuntu的Python3 Certbot为Apache生成SSL证书:

sudo apt install certbot python3-certbot-apache

为*.co配置HTTPS成功:

sudo certbot --apache -d *.co -v

但为*.com执行相同命令时失败:

sudo certbot --apache -d *.com -v

浏览器访问时提示“Server Not Found”错误:

Hmm. We’re having trouble finding that site.

We can’t connect to the server at *.co.

If you entered the right address, you can:
Try again later
Check your network connection
Check that Firefox has permission to access the web (you might be connected but behind a firewall)

疑问

  1. 操作中哪里出现错误?
  2. 是否需要修改DNS记录或Apache配置文件?
  3. Python3 Certbot是否支持HTTPS跳转配置?

内容的提问来源于stack exchange,提问作者Justin Brunkow

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 05:45:13