介绍子域名的建设和使用(前提是主域名已经正确解析到服务器ip)
首先在DNS解析网站添加一个CNAME,在主机或子域名字段中输入你想要的子域名前缀,在目标或指向字段中输入 starry0214.one
(这是我的主域名)(例如你想要使用子域名web_chat,则实际访问链接为web_chat.starry0214.one),示例如下:
相关使用方法:
此处我想通过将所有访问我子域名(web_chat.starry0214.one)的流量全部转发至端口9999,因为我在端口9999部署了一个web项目。在完成了子域名解析后,在服务器的Nginx配置文件添加如下server块代码实现流量处理转发:
server {
listen 9999;
server_name web_chat.starry0214.one;
location / {
proxy_pass http://localhost:9999;
proxy_set_header Host $host;
}
}
/*listen 9999的9999应该替换为你想要的且没被占用的端口, server_name后面替换为你的完整子域名, proxy_pass http://localhost:9999中9999替换为你想要的目标窗口,最后一行不变*/
保存并重启Nginx后,访问你的子域名,就会达到你服务器目标端口下的对应项目。
多个server块中的listen端口可以重复,只要确保server_name不同即可
Some genuinely excellent articles on this web site, thanks for contribution.
The very root of your writing whilst appearing reasonable originally, did not really settle properly with me personally after some time. Someplace throughout the paragraphs you actually were able to make me a believer unfortunately only for a while. I still have got a problem with your leaps in assumptions and you might do well to fill in all those gaps. In the event that you actually can accomplish that, I would surely end up being amazed.
I didn’t quite understand your meaning. Could you please elaborate a bit more?
F*ckin’ remarkable issues here. I’m very happy to peer your post. Thanks so much and i’m having a look forward to contact you. Will you kindly drop me a mail?
I’m really loving the theme/design of your website. Do you ever run into any internet browser compatibility issues? A number of my blog readers have complained about my site not working correctly in Explorer but looks great in Opera. Do you have any solutions to help fix this issue?
Unquestionably believe that which you said. Your favorite reason appeared to be at the internet the easiest factor to bear in mind of. I say to you, I definitely get annoyed whilst other people think about worries that they just don’t recognise about. You managed to hit the nail upon the highest as neatly as outlined out the entire thing without having side-effects , people can take a signal. Will likely be again to get more. Thank you
Thanks for another magnificent article. The place else could anybody get that type of information in such a perfect way of writing? I’ve a presentation subsequent week, and I am on the look for such info.
I’ve been surfing online greater than three hours nowadays, yet I by no means discovered any interesting article like yours. It is pretty value enough for me. In my opinion, if all website owners and bloggers made excellent content as you did, the net shall be much more helpful than ever before.
Very interesting topic, thanks for putting up.
This is a very good tips especially to those new to blogosphere, brief and accurate information… Thanks for sharing this one. A must read article.
Great post. I am facing a couple of these problems.