AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 772568
Accepted
David
David
Asked: 2016-04-25 03:51:38 +0800 CST2016-04-25 03:51:38 +0800 CST 2016-04-25 03:51:38 +0800 CST

排除一个 URL 被重定向到 HTTPS 会生成一个带有当前 NGINX 版本的循环

  • 772

我刚刚将我在 Ubuntu 上的 NGINX 服务器更新到了最新的官方版本 1.9.15。

从那时起,我使用了很长一段时间的配置停止工作。简而言之,我将所有流量重定向到 https,除了一个页面,例如 /mypage/,由于外部资源,该页面需要通过 http 访问。

这就是我的配置的样子。

server {

  listen 12.34.56.78:80;

  server_name www.myside.com;
  root /home/myside.com/public_html;
  index index.php;

  location ~ \.php$ {
    include fastcgi.conf;
    fastcgi_intercept_errors on;
    fastcgi_pass php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }

  location / {
    return 301 https://www.myside.com$request_uri;
    try_files $uri $uri/ /index.php?$args;
  }

      # but no redirect for this particular location:
  location /mypage/ {
    try_files $uri $uri/ /index.php?$args;
  }

}

server {

  listen 12.34.56.78:443 ssl http2 default_server;

  ssl on;
  ssl_certificate /etc/nginx/ssl/myside.com/cert.pem;
  ssl_certificate_key /etc/nginx/ssl/myside.com/privkey.pem;

  server_name www.myside.com myside.com;
  root /home/myside.com/public_html;
  index index.php;

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {
    include fastcgi.conf;
    fastcgi_intercept_errors on;
    fastcgi_pass php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }

  location /mypage/ {
    return 301 http://$server_name$request_uri;
    try_files $uri $uri/ /index.php?$args;
  }

}

不幸的是,它现在正在循环 http -> https -> http -> https 等等。

redirect nginx 301-redirect
  • 1 1 个回答
  • 643 Views

1 个回答

  • Voted
  1. Best Answer
    David
    2016-04-29T01:17:13+08:002016-04-29T01:17:13+08:00

    我终于找到了解决方案。这是由于启用了 Strict-Transport-Security 并将 max-age 设置为一年。

    通过将该行更改为:

        add_header Strict-Transport-Security "max-age=0; includeSubdomains";
    

    最大年龄设置为 0,即禁用。

    更多关于这个https://datatracker.ietf.org/doc/html/draft-ietf-websec-strict-transport-sec-11#section-6.1.1

    • 0

相关问题

  • 301 将根域重定向到 Godaddy Windows 主机帐户上的 www 子域

  • 使用 IIS7 重定向 Godaddy 中的子域

  • apache重写以将文件夹分配给域

  • 如何让 Apache2 重定向到子目录

  • 如何强制我的网址始终以 www 开头?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve