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

安装Certbot(Nginx)后域名显示Amazon Linux 2默认页面求助

问题排查与修复方案

1. 检查Web服务器配置(Apache/Nginx)

Certbot安装后会自动生成SSL站点配置,大概率覆盖了原有的Node.js反向代理规则,需要手动补全:

若使用Apache

  • 列出当前启用的配置文件:sudo ls /etc/httpd/conf.d/
  • 找到Certbot生成的SSL配置(命名格式一般为你的域名-le-ssl.conf),编辑文件:sudo nano /etc/httpd/conf.d/你的域名-le-ssl.conf
  • 在<VirtualHost *:443>代码块内添加反向代理规则(假设Node.js应用端口为3000):
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    
  • 重启Apache生效:sudo systemctl restart httpd

若使用Nginx

  • 列出当前启用的站点配置:sudo ls /etc/nginx/sites-enabled/
  • 找到Certbot生成的SSL配置文件,编辑文件:sudo nano /etc/nginx/sites-enabled/你的域名.conf
  • 在监听443端口的server块内添加反向代理规则:
    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
    
  • 验证配置语法:sudo nginx -t
  • 重启Nginx生效:sudo systemctl restart nginx

2. 禁用默认站点配置

  • Apache:删除或重命名默认配置文件:sudo mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bak
  • Nginx:删除默认启用的站点链接:sudo rm /etc/nginx/sites-enabled/default

3. 确认防火墙规则

确保HTTPS(443端口)已开放:

  • 查看当前规则:sudo firewall-cmd --list-all
  • 若未看到https服务,添加规则并重载:
    sudo firewall-cmd --add-service=https --permanent
    sudo firewall-cmd --reload
    

4. 验证Node.js应用状态

确认应用进程正常运行:

  • 查看进程:ps aux | grep node
  • 若使用systemd托管,检查服务状态:sudo systemctl status 你的Node应用服务名.service

内容的提问来源于stack exchange,提问作者madara uchiha

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 14:15:40