Allow CNAME records to connect to point to my server?

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.

So I am guess to allow users to create CNAME’s to their sub-domain on
our server 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? Is that how it should be
done or is there another way?

Thanks

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,219463,219463#msg-219463

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

Hi there,

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 D. [email protected]

Thanks, the only thing the perl conf is doing is reading a list of
sub-domains and placing them into the config file where server_name is
no different than if I entered them manually. So before a customer
creates a CNAME we’ll need to add their domain into the list of
server_names. Thanks I’ll test this with a few of my own domains

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,219463,219521#msg-219521

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs