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

Nginx报400错误(纯HTTP请求发送至HTTPS端口)的解决求助

Nginx报400错误(纯HTTP请求发送至HTTPS端口)的解决求助

各位大佬好,我最近配置Nginx时遇上了个棘手的问题,一直收到400错误提示“纯HTTP请求发送至HTTPS端口”,折腾好半天都没搞定,有没有人能帮我看看我的配置哪里出问题了呀?

我的Nginx配置代码如下:

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name example.com;
  return 301 https://www.example.com$request_uri;
}

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name www.example.com www1.example.com;
  {{root}}

  {{nginx_access_log}}
  {{nginx_error_log}}

  if ($scheme != "https") {
    rewrite ^ https://$host$uri permanent;
  }
}

我隐约感觉是端口监听和跳转逻辑的问题,但具体哪里不对实在摸不准,麻烦各位帮忙指点下,谢谢啦!

备注:内容来源于stack exchange,提问作者Ritik Barnwal

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.17 08:32:57