如何将主机名重定向到ec2实例?
我有这个域名“suaparte.org”,并且我的网站在 EC2 中运行 http://50.19.242.172 :8080/SuaParte/ 我想将 'suaparte.org' 重定向到 http://50.19.242.172:8080/SuaParte/。
亚马逊为我的弹性 IP 提供了一个公共 dns:ec2-50-19-242-172.compute-1.amazonaws.com
我认为这只是将这个公共 dns 放在我的主机名提供商中,但我想知道他如何知道重定向到 http://50.19.242.172:8080/SuaParte/ ? 而不是我在 glassfish 中部署的其他项目?
I have this domain 'suaparte.org' and I have the website running in a EC2 here http://50.19.242.172:8080/SuaParte/ I would like to redirect 'suaparte.org' to http://50.19.242.172:8080/SuaParte/.
Amazon provied a public dns to my elastic ip : ec2-50-19-242-172.compute-1.amazonaws.com
I think it's just put this public dns in my hostname provider, but I wonder, how he gonna know to redirect to http://50.19.242.172:8080/SuaParte/ ?
And not to other project that I have deployed in my glassfish ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个常见的 Web 服务器问题,并非 Amazon EC2 特有的问题。它的工作方式与任何其他网络服务器上的工作方式几乎相同。
您有几个选项,包括:
将您的 Web 服务器更改为侦听 50.19.242.172 的端口 80,并将 suaparte.org 和 www.suaparte.org 的 DNS 指向解析为 50.19.242.172。如果您在该服务器和该端口上有多个网站,那么您将需要了解如何配置虚拟主机,以便每个网站根据浏览器尝试访问的主机名提供自己的内容。一旦您拥有虚拟主机,您可能只想在“/”处显示主页,或者您可以重定向到“/SuaParte/”路径。
将 suaparte.org 和 www.suaparte.org 的 DNS 指向不同的 Web 服务器(仍在端口 80 上运行),该服务器将浏览器重定向到端口 8080,即 EC2 盒子上的路径 /SuaParte/。最方便的解决方案是您的域名注册商或 DNS 提供商允许您免费设置重定向。您可能会在提供商的 DNS 配置设置下找到此内容。
This is a general web server question and is not specific to Amazon EC2. It works pretty much the same there as on any other web server.
You have a couple options including:
Change your web server to be listening on port 80 of 50.19.242.172 and point your DNS for suaparte.org and www.suaparte.org to resolve to 50.19.242.172. If you have multiple web sites on that server and that port, then you'll want to learn how to configure virtual hosts so that they each serve their own content depending on what hostname the browser is trying to access. Once you have virtual hosts, you may want to simply show the home page at "/" or you can redirect to the "/SuaParte/" path.
Point DNS for suaparte.org and www.suaparte.org to a different web server (still running on port 80) that redirects the browser to port 8080, path /SuaParte/ on your EC2 box. The most convenient solution here would be if your domain registrar or DNS provider allows you to set up a redirect for free. You might find this under the DNS configuration settings of your provider.
DNS 是 IP 的“更好”名称。而已。使用它,您无法指定端口(在您的情况下为
8080
)或 contextPath(在您的情况下为SuaParte
)。为此,您必须在服务器上的端口 80(http 协议的默认端口)上安装 http 服务器。并且访问
http://50.19.242.172:80
时将处理重定向到 http ://50.19.242.172:8080/SuaParte/。其他解决方案是将
glassfish
配置为在端口 80 上运行,然后将您的应用程序部署为默认值(到 contextPath/
)。DNS is a 'better' name for IP. Nothing more. With it you cannot specify port (in your case
8080
) or contextPath (in your caseSuaParte
).To do that you must install a http server on port 80 (default port for http protocol) on your server. And than when accessing
http://50.19.242.172:80
will handle the redirect to http://50.19.242.172:8080/SuaParte/.Other solution is to configure the
glassfish
to run on port 80 and then deploy your app as default (to contextPath/
).