Не мог мешать nginx перенаправить к HTTPS на субдомене

Я пытаюсь иметь высокоуровневую настоятельницу монастыря www.example.com, который является сайтом Wordpress, и я хочу, чтобы он всегда вызвал HTTPS, однако у меня также есть субдомен subdomain.mysite.com, который я хочу быть HTTP только.

Прямо сейчас, с моим набором блока сервера, subdomain.mysite.com продолжает перенаправлять в HTTPS в Firefox, и в хроме я получаю слишком много катастрофических отказов перенаправлений.

Что не так с моим файлом?

Вот мой файл блока сервера:

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

Править: Это заголовки, которые я возвращаю при попытке получить доступ к 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
3
задан 9 April 2017 в 19:50

0 ответов

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

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