Não é possível impedir que o nginx redirecione para HTTPS no subdomínio

2

Estou tentando ter um domian de nível superior www.example.com , que é um site wordpress, e quero que ele force HTTPS, mas também tenho um subdomínio subdomínio .mysite.com que eu quero ser apenas HTTP.

Neste momento, com o conjunto de bloqueios do meu servidor, subdomain.mysite.com continua a redirecionar para o HTTPS , no Firefox, e no Chrome recebo muitos redirecionamentos travar.

O que há de errado com meu arquivo?

Aqui está o meu arquivo de bloqueio de servidor:

# Default server configuration
#
server {
  listen 80;
  listen [::]:80;
  server_name example.com;
  return 301 https://example.com$request_uri;
}

server {
  listen 80;
  listen [::]:80;
  server_name www.example.com;
  return 301 https://www.example.com$request_uri;
 }

server {
  # SSL configuration
  #
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

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

  root /var/www/example.com/html;

  # Add index.php to the list if you are using PHP
  index index.php index.html index.htm index.nginx-debian.html;

  server_name example.com www.example.com;
  include snippets/ssl-example.com.conf;
  include snippets/ssl-params.conf;

  location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    # try_files $uri $uri/ =404;
    try_files $uri $uri/ /index.php?q=$uri&$args;    
  }

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

   error_page 404 /404.html;
   error_page 500 502 503 504 /50x.html;
   location = /50x.html {
     root /usr/share/nginx/html;     
   }

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;    
  }
}


# www.subdomain.example.com
server {
  listen 80;
  server_name www.subdomain.example.com;
  return 301 http://subdomain.example.com$request_uri;
}

server {
  listen 443 ssl http2;
  server_name www.subdomain.example.com;
  return 301 http://subdomain.example.com$request_uri;
}

server {
  # SSL configuration
  #
  listen 443 ssl http2;
  server_name subdomain.example.com;
  return 301 http://subdomain.example.com$request_uri;  
}

# subdomain.example.com
server {
  listen 80;
  server_name subdomain.example.com;
  root /var/www/subdomain.example.com/html;
  index index.php index.html index.htm;    

  # Add index.php to the list if you are using PHP
  index index.php index.html index.htm index.nginx-debian.html;

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

  location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    # try_files $uri $uri/ =404;
    try_files $uri $uri/ /index.php?q=$uri&$args;    
  }

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

   error_page 404 /404.html;
   error_page 500 502 503 504 /50x.html;
   location = /50x.html {
     root /usr/share/nginx/html;     
   }

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

Edit: Estes são os cabeçalhos que eu recebo quando tento acessar subdomain.example.com

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,fr;q=0.6,de;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Cookie:lang=en
Host:subdomain.example.com
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
    
por Amir 09.04.2017 / 18:37

0 respostas