Welcome! Log In Create A New Profile

Advanced

Selective rewrite/redirection

Posted by Fastidious 
Selective rewrite/redirection
December 05, 2015 10:04AM
Hello, everyone, I need some help. I have this:

server {
listen 443 ssl spdy;
server_name example-01.com;
[...]
}

server {
listen 443 ssl spdy;
server_name example-02.com;
[...]
}

server {
listen 443 ssl spdy;
server_name example-03.com;
[...]
}

server {
listen 80;
server_name example-04.com;
[...]
}

server {
listen 80;
server_name example-05.com;
[...]
}

server {
listen 80;
server_name example-06.com;
[...]
}


What I am looking for is to automatically redirect all non-SSL to SSL for those domains (with www, and without) that are running SSL, while still allowing regular non-SSL (with www, and without) access to those domains running without SSL. What would the simplest way be? Thanks!



Edited 1 time(s). Last edit at 12/05/2015 10:06AM by Fastidious.
Re: Selective rewrite/redirection
December 05, 2015 11:36AM
Fastidious Wrote:
-------------------------------------------------------
> What I am looking for is to automatically redirect all non-SSL to SSL
> for those domains (with www, and without) that are running SSL, while
> still allowing regular non-SSL (with www, and without) access to those
> domains running without SSL. What would the simplest way be? Thanks!

Huh? you either redirect all http to https or not, you can't have both. You can partially redirect folders or for example only allow root access via http and the rest https.
You'll have to be a bit more clearer what you want.

The most simplest form is this:

server {
listen 80;
server_name example-04.com;
return 301 https://example-04.com$request_uri;
}

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Selective rewrite/redirection
December 05, 2015 11:49AM
Maybe I wasn't clear enough, of the request got lost in translation. For either, I apologize.

For the domains running on SSL (443), I want all requests on 80 for the same domain to be redirected to their SSL. The domains running on 80 (non-SSL) should just work as they should.
Re: Selective rewrite/redirection
December 05, 2015 01:01PM
Fastidious Wrote:
-------------------------------------------------------
> For the domains running on SSL (443), I want all requests on 80 for
> the same domain to be redirected to their SSL. The domains running on
> 80 (non-SSL) should just work as they should.

Then the example I gave should work as you want, just apply this to the domains you want redirected.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Selective rewrite/redirection
December 05, 2015 03:16PM
Sounds good. Thanks!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 197
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready