nginx: Исключите один путь из ssl

У меня есть эта конфигурация, которая работала отлично (я следовал за некоторыми работами для достижения этого):

server {
  listen 443 ssl spdy;

  server_name mywebsite.com www.mywebsite.com;
  # SSL configuration

  include snippets/ssl-mywebsite.com.conf;
  include snippets/ssl-params.conf;

  # Wordpress plugin Rocket-Nginx configuration
  include rocket-nginx.conf;

  root /var/www/www.mywebsite.com;
  index index.php index.html;

  set $cache_uri $request_uri;

  # POST requests and urls with a query string should always go to PHP
  if ($request_method = POST) {
    set $cache_uri 'null cache';
  }
  if ($query_string != "") {
    set $cache_uri 'null cache';
  }

  # Don't cache uris containing the following segments
  if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
  set $cache_uri 'null cache';
  }

  # Don't use the cache for logged in users or recent commenters
  if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
    set $cache_uri 'null cache';
  }

  location / {
    try_files /wp-content/cache/wp-rocket/$http_host/$cache_uri/index.html $uri/ /index.php?$args;
  }

  location ~ /.well-known {
    allow all;
  }

  location ~ \.(hh|php)$ {
    try_files $uri /index.php;
    fastcgi_keep_conn on;
    fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME
    $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
  location /xmlrpc.php {
    deny all;
  }
}

server {
  listen 80;
  server_name mywebsite.com www.mywebsite.com;

  location / {
    return 301 https://www.mywebsite.com$request_uri;
  }
}

Но теперь я должен перенаправить страницы, содержащие/stats/как это: HTTPS://www.mywebsite.com/STATS/somepage to HTTP://www.mywebsite.com/STATS/somepage. Я хочу исключить тот путь из ssl.

Я попробовал много конфигураций как этот:

server {
    listen 443;

    location ~* ^/(Stats|stats/.*)$ {  # redirect https iframe requests to http server
        return 301 http://www.mywebsite.com$request_uri;
    }
    # ...
}

server {
    listen 80;

    location / {  # the default location redirects to https
        return 301 https://www.mywebsite.com$request_uri;
    }

    location ~* ^/(Stats|stats/.*)$ {}  # do not redirect requests for iframe location

}

но я всегда получаю эту ошибку: 'Слишком многие перенаправление'.

Вы могли сказать мне, как я могу достигнуть этого.

Заранее спасибо

1
задан 17 November 2016 в 00:51

0 ответов

Другие вопросы по тегам:

Похожие вопросы: