nginx - How does the cloud service provide customized domain name services and point this customized domain name to the second-level domain name under the site?
给我你的怀抱
给我你的怀抱 2017-05-16 17:20:23
0
1
607

We now provide cloud services. Customers have an exclusive second-level domain name. Under the access domain name are some customized static and dynamic resources. Now I want to provide the user's own domain name to point to the second-level domain name. The effect achieved is the same as It's the same as GitPages. The user adds his CNNAME, and then points his domain name to my IP (the customer's is the top-level domain name). I have Nginx on the front end that can do this parsing

我现在知道的是,如果我动态的向Nginx的conf文件里添加server,似乎是可以处理这个情况的
请问有经验的朋友给个提示,如果我建立一个Nginx的配置目录,动态的这个目录下添加conf文件,并include这个目录下的所有配置文件,每个文件里写一个server,这样可行吗?
我测试过添加目录,写入配置文件添加server是可以的,但是必须reload Nginx
请问有什么办法,不用手动reload Nginx
给我你的怀抱
给我你的怀抱

reply all(1)
巴扎黑

1) First, you need to place the static files of each customer in a different directory, such as /data/www/site/foo /data/www/site/bar
2) 到你的 DNS 服务商处配置一个范域名,例如 *.statuspage.cn (some DNS service providers may not support it, here we recommend you to use free DNSPod)
3) Configure Nginx as follows

# 部分无关配置已忽略
server {
  server_name  ~^(?<subdomain>.+)\.statuspage.cn;
  root         /data/www/site/$subdomain;
}

4) Now you can visit happily via foo.statuspage.cnbar.statuspage.cn

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!