AWS 53号路线 - 路由通往数字海洋托管项目的路线
我创建了两个新项目,并用同一滴在数字海洋中部署了它。一个是django,第二个是节点JS项目。
该域实际上是在AWS中托管的,因此第一个已经有效的是,
sample.maindomain.com (django)
maindomain.com (nodejs) //currently trying to figure out how route this domain toi nodejs project
可以说数字海洋的IP地址为167.162.169.224,
因此路由53是像这样配置的,
Recordname Type Routing Value/Route traffic to
sample.maindomain.com A Simple 167.162.169.224
maindomain.com A Simple what should be the value ?
我在nginx中创建了两个单独的文件,因为反向曲线看起来像这样
// sample.maindomain.com(django)
server {
Server_name sample.maindomain.com www.sample.maindomain.com
location /
................
// maindomain.com(nodejs)
server {
server_name maindomain.com www.maindomain.com
root /home/projectdir/nodejsproject;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}}
....................
.......................
,所以问题是,我如何路由 maindomain.com
,因此它将指向nodejs project nginx nginx nginx配置海洋?
实际上,如果该项目部署在EC2实例中,则将域或子域指向cname的添加子域更容易,例如 EC2-19-19-192-192-107-202.EU-CENTRAL-12.EU-CENTRAL-1.COM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须将同一个公共IP用于两个主机名,并根据Web请求的
主机
字段向右后端发送液滴发送请求。所谓的
虚拟托管
。有很多示例如何使用nginx进行操作,这只是一个随机的示例:https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks- Virtual-Hosts-on-ubuntu-16-04
You have to use the same public IP for both hostnames and make your droplet send requests to the right backend based on the
Host
field of the web requests.What is called
Virtual Hosting
.There are a lot of examples how to do that with nginx, this is just a random one: https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
我试图删除和重新创建虚拟设施并重新启动服务器几次,但它不起作用。Nginx配置是正确的,指向精确的项目位置,但仍然指向其他工作项目。
经过大量谷歌搜索后,我意识到我需要在项目中添加SSL证书并使用Certbot https://www.nginx.com/blog/ususe-free-ssltls-certificates-from-lem-lets-cerrypt-encrypt-with-nginx/
我是不知道为什么添加SSL证书为我解决了问题
I tried to delete and recreate the virtualhosts and restarting the server few times but it did not working.The nginx config is correct and pointing to exact project location but still its pointing to other working project.
After many googling, I realised that I need to add ssl certificate to the project and install it using certbot https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/
I am not sure why after adding ssl certificate solves the problem for me