A
A
Artem Lisovsky2014-08-06 12:32:57
Nginx
Artem Lisovsky, 2014-08-06 12:32:57

How to configure access to a folder on a server with nginx from any subdomain?

Faced with an interesting task - we have a server with nginx on board, ip-address 1.2.3.4. The site.com domain is bound to the server.
I would like to do a simple thing - so that any Internet user, specifying CNAME in the DNS settings of any of his domain (or subdomain) on 1.2.3.4, receives information from a folder from the server 1.2.3.4.
For example, I have a domain xeday.ru. I want the content in the site.com/media/ folder to be available at media.xeday.ru/ To do this, I need to do one simple action - set my domain's DNS in the settings:
media.xeday.ru CNAME 1.2.3.4
What is the best way to configure nginx for such a task?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad Zhivotnev, 2014-08-06
@torrie

You don't explain the problem clearly, but I'm assuming it's like this:

server { 
server_name site.com;
... конфиг для него ... ;
} 
server {
server_name ~^(?<subdomain>[a-z0-9\-]+)\.site\.com;
root /blah/bla/$subdomain;
... остальной конфиг; 
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question