【问题标题】:How to turn off ssl for specific url?如何关闭特定网址的 ssl?
【发布时间】:2016-07-15 19:46:43
【问题描述】:

这是我的配置:

upstream example {
  server unix:///home/deploy/apps/example/shared/tmp/sockets/example-puma.sock;
}

server {
    listen 80 default_server;
    server_name example.org;

    location /non_https {
        proxy_pass http://example;
    }

    return 301 https://$server_name$request_uri;
}
server {

  listen 443 ssl default_server;

  ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
  include snippets/ssl-params.conf;

  root /home/deploy/apps/example/current/public;

  try_files $uri/index.html $uri @example;
  location @example {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://example;
  }

  keepalive_timeout 10;
}

我需要关闭ssl for /non_https/*如何获取?

【问题讨论】:

  • 警告:这样做是不安全的,因为这意味着你不能使用 HSTS,所以所有 https 页面都容易受到 sslstrip 攻击。
  • 但是我只想在特定的url上关闭https,其他url应该使用https
  • 这是我的观点:您不能使用 HSTS,因为您需要在某些 url 上使用 http。其他带有 https 的 url 很容易受到 sslstrip 的攻击,因为您不使用 HSTS。一个解决方案可能是为 http url 使用另一个域。请问为什么需要http?
  • 外部系统需要http,不能使用https。为什么所有 https 页面都容易受到攻击?我可以将 subdomain.example.org 用于 http,但无论如何它都会在同一个 IP 上?
  • 如果是不支持https的系统,可以激活HSTS,只为该系统保留http。请记住:HSTS 是针对 mitm/sslstrip 的唯一保护措施。而且,我希望与外部系统的通信不涉及任何敏感/个人数据。

标签: http redirect nginx https


【解决方案1】:

如果您将 retuen 301 放在位置“/”块内,它应该可以工作:

server {
    listen 80 default_server;
    server_name example.org;

    location /non_https {
        proxy_pass http://example;
    }

    location / {
        return 301 https://$server_name$request_uri;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多