nginx: Excluir um caminho do ssl

1

Eu tenho essa configuração que estava funcionando muito bem (eu segui alguns passos para conseguir isso):

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

Mas agora preciso redirecionar as páginas que contêm / stats / assim: HTTPS://www.mywebsite.com/STATS/somepage to HTTP://www.mywebsite.com/STATS/somepage. Eu quero excluir esse caminho do SSL.

Eu tentei várias configurações como esta:

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

}

mas eu sempre recebo este erro: 'Muitos redirecionamentos'.

Poderia, por favor, me dizer como posso conseguir isso?

Obrigado antecipadamente

    
por Charaf Erraiss 16.11.2016 / 21:57

0 respostas