Nginx HTTP到HTTPS 301循环重定向

问题描述 投票:0回答:1

我需要为整个站点进行HTTP-> HTTPS重定向,但每次我收到301循环重定向的错误消息。请更正我的conf以获得301错误。这是我的conf文件:

upstream live {
  server IP:PORT;
  }
server {
      listen      80 default;
      server_name mysite.com;
      access_log  off;
      error_log   off;
      root /usr/share/nginx/html/;
      index index.html index.htm;
      return 301 https://$host$request_uri;
}
server {
      listen 443;
      root /usr/share/nginx/html/;
      index index.html index.htm;
      rewrite_log on;
      server_name mysite.com;
      access_log /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log debug;
      client_max_body_size 200m;

      location / {
        index index.html index.htm;
      try_files $uri $uri/ /index.html?$uri&$args;
      }

      location /web {
        proxy_pass https://live/gateway/web;
        proxy_set_header "MP_FRONT" aaa;
        proxy_pass_request_headers      on;
      }
}

enter image description here

nginx https http-status-code-301
1个回答
0
投票

只是尝试替换下面的第一个服务器JSON

server {
    listen 80;
    listen [::]:80 default_server ipv6only=on;
    server_name example.com;
    return 301 https://www.example.com$request_uri;
}

请尝试让我知道它是否适合你

© www.soinside.com 2019 - 2024. All rights reserved.