nginx - NGINX 重定向到 www 域不起作用
问题描述
我有一个包含在 nginx.conf 中的 mywebsite.conf。文件是这样的:
server {
listen 80;
server_name www.mywebsite.nl;
return 301 https://www.mywebsite.nl$request_uri;
}
server {
listen 80;
server_name mywebsite.nl;
return 301 https://www.mywebsite.nl$request_uri;
}
server {
listen 443 ssl;
server_name mywebsite.nl;
...
return 301 https://www.mywebsite.nl$request_uri;
}
server {
listen 443 ssl http2;
server_name www.mywebsite.nl;
...
}
此配置适用于我所有的网站。但不知何故,这次http://mywebsite.nl没有重定向到https://www.mywebsite.nl。
我不知道为什么。DNS 指向服务器。缓存是隐身的。
我重新加载并重新启动了nginx。尝试了新的浏览器。使用https://wheregoes.com对其进行测试。
有任何想法吗?
curl的输出是:
* Trying 37.97.xxx.xx...
* TCP_NODELAY set
* Connected to mywebsite.nl (37.97.xxx.xx) port 80 (#0)
> HEAD / HTTP/1.1
> Host: mywebsite.nl
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Server: nginx/1.14.0 (Ubuntu)
Server: nginx/1.14.0 (Ubuntu)
< Date: Wed, 14 Jul 2021 05:55:03 GMT
Date: Wed, 14 Jul 2021 05:55:03 GMT
< Content-Type: text/html
Content-Type: text/html
< Content-Length: 612
Content-Length: 612
< Last-Modified: Wed, 17 Apr 2019 18:42:45 GMT
Last-Modified: Wed, 17 Apr 2019 18:42:45 GMT
< Connection: keep-alive
Connection: keep-alive
< ETag: "5cb773a5-264"
ETag: "5cb773a5-264"
< Accept-Ranges: bytes
Accept-Ranges: bytes
解决方案
推荐阅读
- azure-cosmosdb - 使用 .NET SDK 在 Cosmos DB 中批量删除支持
- ruby-on-rails - Herkou Redis - 证书验证失败(证书链中的自签名证书)
- c# - 如何使用 ServiceStack 和 Angular 下载动态生成的 XML 文件?
- c++ - 为什么我的 C++ 并行程序在 MPI_Gather 中出现 MPI 致命错误?
- python - 计算点Python的突然变化
- python - 尝试在 np.sum 中使用复数时,为什么会收到消息“TypeError:'complex' object is not subscriptable”?
- next.js - 如何在生产环境中重建 NextJS 项目
- arrays - 谷歌表格查询功能
- c++ - 有什么理由使用 std::thread 而不是 std::jthread?
- python - 将类对象动态分配给函数