By aloncarmel
Ok, The title sounds very problematic… My current stack is a single server, with nginx as front server and a nodejs server in the back along side some apache virtual hosts.
The nginx has multiple virtual hosts per domain. everything works just fine.
This is where it gets complicated. One of my hosted nodejs apps accepts subdomains as var (i.e http://9374e93535f77f33.pages.bootlander.com) this is proxy_forward to http://nodejs:port/t/$subdomain which works great.
What i want todo is offer the option to let my customers put a DNS CNAME record on their DNS server that will take http://anysub.theirowndomain.com => http://9374e93535f77f33.pages.bootlander.com.
When i did a test for this, the default first nginx virtual host loaded up and not the http://9374e93535f77f33.pages.bootlander.com content.
What can i do?
This is the subdomains server block on nginx:
listen 80;
server_name ~^([a-z0-9]+)\.pages\.bootlander\.com$;
set $sub $1;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://nodejs:port/t/$sub;
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
You will need to set server_name to whatever record your customers use to reach the site, otherwise nginx will load the default site. Your config at the moment will only work if a user directly enters *.pages.bootlander.com in their browser.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.