ubuntu - Nginx 重定向问题
问题描述
我在 ubunto 18.4 上安装了 nginx,并在 /var/www/html 路径中创建了带有“你好世界”消息的 html 页面。
我创建自签名 SSL 证书,使用本指南链接
我想将所有流量从 HTTP 重定向到 HTTPS。
这是 /etc/nginx/sites-available/default 文件配置:
server {
listen 443 ssl;
listen [::]:443 ssl;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
server {
listen 80;
listen [::]:80;
server_name _;
return 301 https://35.180.25.62$request_uri;
}
问题:
在浏览器中,当我输入https://35.180.25.62 - 我得到“万圣节”页面。(好的)
但是,当我输入http://35.180.25.62 - 我没有得到“神圣世界”页面。(坏的)
我希望当我输入http://35.180.25.62时- nginx 将使用 ssl 并向我显示“万圣节”页面。
我也注意到——
1.当我在浏览器中输入http://35.180.25.62时,我在浏览器开发者工具(f12)中检查,重定向带我到5.180.25.62 insted 35.180.25.62!!! 为什么? 看图片
2.只有当我输入http://35.180.25.62/index.html - 重定向很好,我得到了“万圣节”页面。为什么当我输入https://35.180.25.62我不必写 'index.html' ,但在 http 我有?
解决方案
推荐阅读
- vba - 将电子邮件附件名称添加到我的报表 Outlook
- algorithm - 围绕圆计算点
- raspberry-pi - 如何让 Raspberry Pi 成为 VoIP ATA 设备
- python - 将列表项转换为具有默认值的 dict 键
- bash - 为什么我的 cron 作业不能正常执行?
- python - 在 youtube-dl python 脚本中,我应该在哪里放置命令参数?
- javascript - 如何使用 javascript 在数据透视表中插入 :nth-child(x) 和 :before?
- shell - 向包装外壳脚本添加参数
- formatting - 有没有办法将 Zapier 格式化程序查找表从一个 zap 复制到另一个 zap?
- sql - 我对我的 SQL 连接感到困惑,因为它返回的结果与我的预期不同