too many redirects

Francis Daly francis at daoine.org
Fri Nov 21 19:29:57 UTC 2014


On Fri, Nov 21, 2014 at 09:02:01AM +0100, JACK LINKERS wrote:

Hi there,

> As you can see, the template doesn't make separate server blocks for each
> HTTP & HTTPS protocole :

This part is still true:

> > What you probably want is:
> >
> >  listen on http; redirect everything to https.
> >  listen on https; process requests normally.

but your particular access to configure nginx does not appear to allow
you do that.

The right answer is for you to change your access to configure nginx;
but that is unlikely to happen in the short term.

You can use an alternative config, along the lines of:

 listen on http and https; if the request was http, redirect to https;
  else process requests normally

That will probably fit your restricted configuration model.

Add a stanza at server{} level, outside all location{}s

  if ($scheme = "http") {
    return 301 https://$server_name$request_uri;
  }

and reload, and see if that does what you want.

You may want to replace $server_name with $host or your preferred host
name directly, depending on what exactly you want.

But it should get over the infinite loop of your original config.

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list