# Allow CNAME records to connect to point to my server?

**URL:** <https://www.ruby-forum.com/t/allow-cname-records-to-connect-to-point-to-my-server/214455>\
**Category:** NGINX\
**Created:** [December 2, 2011, 10:38am UTC](https://www.ruby-forum.com/t/allow-cname-records-to-connect-to-point-to-my-server/214455 "2011-12-02T10:38:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [December 2, 2011, 10:38am UTC](https://www.ruby-forum.com/t/allow-cname-records-to-connect-to-point-to-my-server/214455/1 "2011-12-02T10:38:14Z")

</div>

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](http://username.ourwebapp.com)

[customersdomain.com](http://customersdomain.com) =\> CNAME [username.ourwebapp.com](http://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:

> **[Allow CNAME records to connect to point to my server?](https://forum.nginx.org/read.php?2,219463,219463#msg-219463)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![anagio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@anagio](https://www.ruby-forum.com/u/anagio)\
**Post date:** [December 2, 2011, 11:18pm UTC](https://www.ruby-forum.com/t/allow-cname-records-to-connect-to-point-to-my-server/214455/2 "2011-12-02T23:18:59Z")

</div>

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  
[Server names](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](http://username.ourwebapp.com)”, you make it “server\_name  
[username.ourwebapp.com](http://username.ourwebapp.com) [customersdomain.com](http://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](http://customersdomain.com) in the same  
way it treats [username.ourwebapp.com](http://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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![anagio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@anagio](https://www.ruby-forum.com/u/anagio)\
**Post date:** [December 3, 2011, 2:37am UTC](https://www.ruby-forum.com/t/allow-cname-records-to-connect-to-point-to-my-server/214455/3 "2011-12-03T02:37:25Z")

</div>

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:

> **[Re: Allow CNAME records to connect to point to my server?](https://forum.nginx.org/read.php?2,219463,219521#msg-219521)**
>
> 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...
