0

I am trying to configure wildcard subdomains for my app but whenever I enter the subdomain I receive my root domain's index page. My app is configured through cloudflare and then I have an Nginx server that either serves the static files or pipes the request to a node app.

Within cloudflare I've added two rules in this order

http://*domain.com/*
 -always use https

http://*.domain.com
 -always use https

Then within nginx I have two server blocks

server
{
  listen 80;
  server_name www.domain.com domain.com;

  //this will redirect user to use https
}
server
{
  listen 443;

  //this is my root domain's server that should handle all traffic for the root domain
}

then I have a block for the subdomains

server
{
   listen 443;
   server_name ~[^(www)|0-9A-Z]\.domain.com
   //proxies the request to the node app
}

The strange thing is that I am seeing the request being handled by the correct routes within the node app but I am getting the wrong file (the root domain's index page).

I am a bit confused since at first I suspected it might have been cloudflare caching the index page and serving that for all subdomains but then if that were the case why I am able to see the requests reaching my server?

naughty boy
  • 2,089
  • 3
  • 18
  • 28
  • That regex is wrong. You seem to have an incomplete character class and/or used brackets where parenthesis should be. What exactly are you trying to match? – Richard Smith Apr 06 '16 at 08:09
  • Also, [see this answer](http://stackoverflow.com/questions/35037510/how-to-exclude-specific-subdomains-server-name-in-nginx-configuration/35039222#35039222) for alternative to using regex by using a default server for the subdomains instead. – Richard Smith Apr 06 '16 at 08:25

0 Answers0