title: Nginx redirects to only one domain
body: <p>I made a backup of Nginx vhosts configuration file before re-install Debian. When I put them back to the server it redirects only to one website and I don't know where is the problem given that all was working well before and I kept the same configuration files. Here they are : </p>
  
  <p>Nginx.conf : </p>
  
  <pre><code>user www-data;
  worker_processes 4;
  pid /run/nginx.pid;
  
  events {
  worker_connections 768;
  # multi_accept on;
  }
  
  http {
  
  ##
  # Security Settings
  ##
  
  server_tokens off;
  add_header X-Frame-Options SAMEORIGIN;
  add_header X-Content-Type-Options nosniff;
  add_header X-XSS-Protection "1; mode=block";
  
  #add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://ssl.google-analytics.com https://assets.zendesk.com https://connect.facebook.net; img-src 'self' https://ssl.google-analytics.com https://s-static.ak.facebook.com https://assets.zendesk.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://assets.zendesk.com; font-src 'self' https://themes.googleusercontent.com; frame-src https://assets.zendesk.com https://www.facebook.com https://s-static.ak.facebook.com https://tautt.zendesk.com; object-src 'none'";
  
  
  ##
  # Basic Settings
  ##
  
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  
  # server_names_hash_bucket_size 64;
  # server_name_in_redirect off;
  
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  
  ##
  # SSL Settings
  ##
  
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;
  
  ##
  # Logging Settings
  ##
  
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;
  
  ##
  # Gzip Settings
  ##
  
  gzip on;
  gzip_disable "msie6";
  
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
  
  ##
  # Virtual Host Configs
  ##
  
  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
  }
  
  
  #mail {
  #   # See sample authentication script at:
  #   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
  #
  #   # auth_http localhost/auth.php;
  #   # pop3_capabilities "TOP" "USER";
  #   # imap_capabilities "IMAP4rev1" "UIDPLUS";
  #
  #   server {
  #       listen     localhost:110;
  #       protocol   pop3;
  #       proxy      on;
  #   }
  #
  #   server {
  #       listen     localhost:143;
  #       protocol   imap;
  #       proxy      on;
  #   }
  #}
  </code></pre>
  
  <p>Website1 conf : </p>
  
  <pre><code>server {
      server_name website1.com;
      rewrite ^/(.*)$ http://www.website1.com/$1 permanent;
  }
  server {
      listen   80;
      root /opt/http/nginx/sites/website1/www;
      index index.php index.html;
      server_name www.website1.com;
  
      location / {
          try_files $uri $uri/ /index.php;
      }
  
      location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
          expires 365d;
      }
  
      location ~*  \.(pdf)$ {
          expires 30d;
      }
  
      location /blog/post/ {
          rewrite ^/blog/post/([\w-]+)-(\d+)$ /blog/post.php?url=$1&amp;id=$2;
      }
  
      client_max_body_size 3M;
  
      error_page 403 /index.php;
  
      # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_pass unix:/var/run/php5-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
      }
  
     # gzip on;
     # gzip_min_length  1100;
     # gzip_buffers  4 32k;
     # gzip_types    text/plain application/x-javascript text/xml text/css;
     # gzip_vary on;
  
      access_log   /var/log/nginx/www.website1.access.log;
      error_log   /var/log/nginx/www.website1.error.log;
  }
  </code></pre>
  
  <p>And website2 conf (same as above except the name) :</p>
  
  <pre><code>server {
      server_name website2.com;
      rewrite ^/(.*)$ http://www.website2.com/$1 permanent;
  }
  server {
      listen   80;
      root /opt/http/nginx/sites/website2/www;
      index index.php index.html;
      server_name www.website2.com;
  
      location / {
          try_files $uri $uri/ /index.php;
      }
  
      location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
          expires 365d;
      }
  
      location ~*  \.(pdf)$ {
          expires 30d;
      }
  
      client_max_body_size 3M;
  
      error_page 403 /index.php;
  
      # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_pass unix:/var/run/php5-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
      }
  
     # gzip on;
     # gzip_min_length  1100;
     # gzip_buffers  4 32k;
     # gzip_types    text/plain application/x-javascript text/xml text/css;
     # gzip_vary on;
  
      access_log   /var/log/nginx/www.website2.access.log;
      error_log   /var/log/nginx/www.website2.error.log;
  }
  </code></pre>
  
  <p>So when I try to access website2.com it redirects me to website1.com (always with 'www' because I want it). But I don't understand where it could come from.</p>