Allow CNAME records to connect to point to my server?

Francis Daly francis at
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;
> => CNAME
> 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 for how things work.

If you're not doing anything clever within nginx, then where you currently
have "server_name", you make it "server_name", 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 in the same
way it treats

> 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,

Francis Daly        francis at

More information about the nginx mailing list