Allow CNAME records to connect to point to my server?

Francis Daly francis at daoine.org
Fri Dec 2 22:18:37 UTC 2011


On Fri, Dec 02, 2011 at 04:37:40AM -0500, anagio wrote:

Hi there,

> Our web app gives each user a sub-domain. I'd like to offer some larger
> plans CNAME's so they can point one of their own domain names with a
> CNAME to their sub-domain on our server 
> 
> ie; username.ourwebapp.com
> 
> customersdomain.com => CNAME username.ourwebapp.com
> 
> Our NGINX server is configured with wild card sub-domains, but uses a
> perl conf to read valid sub-domains from a file. If the sub-domain
> doesn't exist they get a 404.

CNAME is just a way to get the web traffic to your IP address. The
request will still include the original name in the Host: header.

nginx cares about the Host: header and the
server_name configuration directive -- see for example
http://nginx.org/en/docs/http/server_names.html for how things work.

If you're not doing anything clever within nginx, then where you currently
have "server_name username.ourwebapp.com", you make it "server_name
username.ourwebapp.com customersdomain.com", and it should Just Work.

It sounds like you *are* doing something clever, where nginx accepts all
Host: names and your extra system decides how to proceed. In that case,
you'll want your extra system to treat customersdomain.com in the same
way it treats username.ourwebapp.com.

> we will need to create a name based virtual host and a new
> config file in sites-available include their subdomain on our server, as
> well as an alias of the customers own domain? 

You'll need to ensure that one server{} block handles the customer's
domain, and one server{} block handles your subdomain, and that they
each do the Right Thing. They can be the same server{} block.

The implementation details really depend on what your perl conf and your
web app do.

Good luck,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list