1

I have some questions regarding Nginx configuration with wildcard subdomains, and then how custom domains come into the picture. Here is my situation.

Let's say I own the site awesome.com. When a user signs up for my site, they automatically get a subdomain. So user Steve could navigate to his homepage via steve.awesome.com. To accomplish this, create a wildcard subdomain CNAME record. Internally, I want the application to treat this as awesome.com/users/steve. After viewing this post, I believe I should be able to rewrite the route to my desired result, without actually changing what the URL displays in the browser.

Now, I want to allow Steve to set up his own custom domain. Let's say Steve owns the domain iamsteve.com. Steve could then point his domain, to his subdomain steve.awesome.com.

My main question is, when a request is made to iamsteve.com, will my Nginx server receive the request as steve.awesome.com, thus allowing the rewrite logic to still work correctly? Or will it actually receive the request as iamsteve.com?

1 Answers1

1

The web browser sends whatever hostname is in the URL for the requested resource in the Host header.

Eg, user navigates to http://foo.example/bar, the header will be Host: foo.example. The name resolution process does not affect this.

Håkan Lindqvist
  • 35,011
  • 5
  • 69
  • 94