MattM
MattM

Reputation: 817

nginx redirect only fails with firefox

I am using the following config file for nginx and it works fine with Chrome but not with Firefox. With Firefox, I get the following error:

"Firefox has detected that the server is redirecting the request for 
this address in a way that will never complete."

Clearing the cookies and cache if Firefox does not help.

upstream dev_server {
  server 127.0.0.1:8100 fail_timeout=0;
}

server {
  listen 80;
  server_name subdomain.pro.domain.com;
  location /blog {
    proxy_pass http://dev_server;

    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

    proxy_set_header  Accept-Encoding "";
    proxy_set_header  Host $host;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  X-Forwarded-Proto $scheme;
    add_header        Front-End-Https   on;

    proxy_redirect    off;
  }
  location / {
    rewrite     ^(.*)$ https://subdomain.pro.domain.com$1;
  }
}

server {
  listen              443;
  ssl                 on;
  server_name         subdomain.pro.domain.com;

  ssl_certificate     /etc/nginx/star.pro.domain.com.crt;
  ssl_certificate_key /etc/nginx/star.pro.domain.com.key;

  ### SSL settings here ###
  ssl_protocols       SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers         RC4:HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers on;
  keepalive_timeout   60;
  ssl_session_cache   shared:SSL:10m;
  ssl_session_timeout 10m;

  add_header Strict-Transport-Security max-age=500;

  location /blog {
    rewrite     ^(.*)$ http://subdomain.pro.domain.com$1;
  }

  location / {
    proxy_pass http://dev_server;

    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

    proxy_set_header  Accept-Encoding "";
    proxy_set_header  Host $http_host;
    proxy_set_header  X-M-Secure "true";
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  X-Forwarded-Proto $scheme;
    add_header        Front-End-Https   on;
    proxy_max_temp_file_size 0;

    proxy_redirect    off;
  }
}

Upvotes: 1

Views: 2908

Answers (1)

MattM
MattM

Reputation: 817

Found the issue.

Because the /blog redirected to HTTP and all other paths redirected to HTTPS, the problem was with the following configuration line:

add_header Strict-Transport-Security max-age=500;

When I commented out that line, the issue went away.

Upvotes: 1

Related Questions