简体   繁体   English

更改AWS ec2实例的主机名

[英]Change hostname for AWS ec2 instance

I have an AWS EC2 instance with domain like http://ec2-some-ip-addres.compute-1.amazonaws.com/ 我有一个AWS EC2实例,其域名为http://ec2-some-ip-addres.compute-1.amazonaws.com/

Now I want to change this url (add a custom domain which is not registered) to some small alias like testing.webserver.com etc. Can we do that? 现在我想将这个URL(添加一个未注册的自定义域)更改为一些小别名,例如testing.webserver.com等。我们可以这样做吗?

I have tried editing /etc/hosts file with 我试过用/编辑/ etc / hosts文件

ip-address hostname alias

But not working. 但不行。 What is the best way to change the url without making a DNS entry on no-ip or some other services? 如果不在no-ip或其他服务上进行DNS输入,更改URL的最佳方法是什么?

To access an Amazon EC2 instance with your own domain name, use a DNS server (eg Amazon Route 53) to point your domain name to the IP address of the EC2 instance. 要使用您自己的域名访问Amazon EC2实例,请使用DNS服务器(例如Amazon Route 53)将您的域名指向EC2实例的IP地址。

The steps are: 步骤是:

  • Create an Elastic IP address in the EC2 management console. 在EC2管理控制台中创建弹性IP地址。 This is a static IP address that you can then control. 这是您可以控制的静态IP地址。
  • Assign the Elastic IP address to your EC2 instance 将弹性IP地址分配给EC2实例
  • Choose a DNS provider (either your own, or Amazon Route 53) 选择DNS提供商(您自己的或Amazon Route 53)
  • Purchase your domain name (in case you don't already own it), eg example.com 购买您的域名(如果您还没有域名),例如example.com
  • Create a subdomain (eg server1.example.com 创建子域(例如server1.example.com
  • Create an A record in the DNS system to point to the Elastic IP address 在DNS系统中创建A记录,指向弹性IP地址

You can then access your instance via server1.example.com . 然后,您可以通过server1.example.com访问您的实例。

See also: Routing Queries to an Amazon EC2 Instance 另请参阅:将查询路由到Amazon EC2实例

You can't change it as it depends upon ec2 servers Private and Public IP . 您无法更改它,因为它取决于ec2服务器专用和公共IP Although you can change the public and private IP. 虽然您可以更改公共和私有IP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM