Welcome! Log In Create A New Profile

Advanced

Re: WildCard domains : how to treat IP Address and Specific Domains differently from Failover/Wildcard Domains ?

Francis Daly
March 01, 2013 07:46PM
On Fri, Mar 01, 2013 at 03:20:10PM -0500, Jonathan Vanasco wrote:

Hi there,

> Requests for example.com
> Serve Site A
>
> All IP Address Requests :
> Serve Site A
>
> All other domains ( wildcard / failover )
> Serve Site B
>
> I've tried several combinations of listen + server name, but I can't get this right. I end up sending everything to site A or site B.

You've seen http://nginx.org/en/docs/http/request_processing.html ?

And http://nginx.org/r/listen and http://nginx.org/r/server_name ?

You need the same "listen" ip:port in all servers -- simplest is to
leave it at the default.

The you need the correct "server_name" directives in the correct server{}
blocks.

B should be the default, so put it first:

server {
return 200 "site B\n";
}

A should match the exact hostname example.com, and anything that is just
numbers and dots:

server {
server_name example.com;
server_name ~^[0-9.]*$;
return 200 "site A\n";
}

Because of the default value of server_name, a request with no "host"
will match B. You can make it match A easily enough.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

WildCard domains : how to treat IP Address and Specific Domains differently from Failover/Wildcard Domains ?

Jonathan Vanasco March 01, 2013 03:22PM

Re: WildCard domains : how to treat IP Address and Specific Domains differently from Failover/Wildcard Domains ?

Francis Daly March 01, 2013 07:46PM

Re: WildCard domains : how to treat IP Address and Specific Domains differently from Failover/Wildcard Domains ?

Igor Sysoev March 02, 2013 01:36AM

Re: WildCard domains : how to treat IP Address and Specific Domains differently from Failover/Wildcard Domains ?

Jonathan Vanasco March 03, 2013 03:00PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 209
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready