如何关闭特定网址的ssl?

时间:2016-07-15 19:46:44

标签: http redirect nginx https

这是我的配置:

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;
}

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

1 个答案:

答案 0 :(得分:0)

如果您将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;
    }
}