记录一下域名解析问题(http转https,xxx.com转www.xxx.com失效)

2 篇文章 0 订阅
2 篇文章 0 订阅

问题描述

        在购买了域名 rendshub.today 后,做了基本的nginx配置,但是在输入一些列网址后页面解析会出现请求失败,DNS解析问题,比如希望输入以下网址时,最终转成 https://www.trendshub.today,但最终只有www.trendshub.com和http://www.trendshub.today自动转成功了

trendshub.today
www.trendshub.today
http://trendshub.today

http://www.trendshub.today
http://trendshub.today
https://trendshub.today 

 我的 nginx 配置如下:

server {
    listen 80;
    server_name trendshub.today;

    # 重定向所有 http 请求到 https://www.trendshub.today
    return 301 https://www.trendshub.today$request_uri;
}

server {
    listen 80;
    server_name www.trendshub.today;

    # 重定向所有 http 请求到 https
    return 301 https://www.trendshub.today$request_uri;
}

server {
    listen 443 ssl http2;
    server_name trendshub.today;

    ssl_certificate /etc/nginx/SSL/trendshub.today.pem;
    ssl_certificate_key /etc/nginx/SSL/trendshub.today.key;

    # 重定向所有 https 请求到 https://www.trendshub.today
    return 301 https://www.trendshub.today$request_uri;
}

server {
    listen 443 ssl http2;
    server_name www.trendshub.today;

    ssl_certificate /etc/nginx/SSL/trendshub.today.pem;
    ssl_certificate_key /etc/nginx/SSL/trendshub.today.key;

    # 将根路径的请求代理到端口 3000
    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

解决思路及方案

1. 首先排查了下nginx的配置问题,且对比了下 gpt 的答案,看起来没有问题

2. chrome 浏览器报错信息是

无法访问此网站检查 trendshub.today 中是否有拼写错误。 如果拼写无误,请尝试运行 Windows 网络诊断。 DNS_PROBE_FINISHED_NXDOMAIN

由此将问题聚焦到了dns解析的问题上

利用如下指令,查看域名是否正确指向服务器ip

nslookup trendshub.today
nslookup www.trendshub.today

发现 trendshub.today 的dns记录没有添加顶级域名,所以需要在阿里云域名解析添加@记录即可

完结撒花~~~

  • 7
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值