2015-06-23 56 views
0

我们现有域名如何指向HostGator的域名EC2 AWS

(前。webdev.com)

位于HostGator的,我们在AWS服务器。我们想利用我们从HostGator的

(webdev.com)

在我们的AWS服务器购买域名。

我们在hostgator中创建了一个DNS(project1.webdev.com),地址指向我们的AWS服务器(例如150.12.1.0)。在我们的AWS,我们部署在端口4000

的PROJECT1现在,如果我们访问

project1.webdev.com

我们最终在默认的Apache网页。我们怎么能路由到我们的4000端口,这样每次我们访问project1.webdev.com它指出了我们的

150.12.1.0:4000

项目。

这里是我们的虚拟主机配置:

<VirtualHost *:4000> 
ServerName project1.webdev.com 
ServerAdmin [email protected] 
DocumentRoot "/var/www/html/project1/web" 

<Directory "/var/www/html/project1/web"> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 

ErrorLog ${APACHE_LOG_DIR}/4000-error_log 
CustomLog ${APACHE_LOG_DIR}/4000-access_log common 

我们已经看过了几个信息,但我们没有发现任何可能的解决方案。期待您的帮助。

感谢

回答

2

你混淆DNS,它与IP地址,与港口,里面什么都没有做DNS做。 DNS仅处理在人类可读名称和IP地址之间转换。 DNS不提供任何类型的规定来执行任务,如“当用户想要使用端口4000而不是端口80进行HTTP请求时”。

如果您的服务正在侦听端口4000,但您使用的HTTP协议(这总是默认使用端口80),那么你就需要通过以下方式之一来处理这个:

  • 要求所有的URL明确指定端口4000,例如:http://project1.webdev.com:4000
  • 更改您的虚拟主机定义侦听端口80,而不是4000
  • 在Apache的80端口添加新的虚拟主机定义,proxies all requests端口4000
+0

嗨@Bruce,谢谢你的回复。如果我们采用这种方法,这是否会让我们的服务器仅限于在端口4000上侦听,我们可以部署另一个项目(project2.webdev.com)并在端口3000中。是否有可能在Linux中在apache中创建逻辑,即,过滤DNS地址/域并重定向到特定端口?. – chkm8

+0

要做这样的事情,你需要设置多个VirtualHost指令,这些指令都监听端口80(这是虚拟主机的用途)。端口80上的虚拟主机A将代理到端口3000的所有连接,端口80上的虚拟主机B将代理到端口4000的所有连接等。 –

+0

嘿@Bruce,非常感谢。你节省了我们的一天。 :)。我们创建了两个80端口实例,每个实例都被重定向到我们项目的特定目录。 – chkm8

0

与我们分享您的解决方案。感谢@Bruce帮助我们。正如他在上面评论中所建议的那样,我们将创建一个移植到80的虚拟主机(这是apache的默认主机)。然后我们将把80号港口转到我们的特定项目。

<VirtualHost *:80> 
    # The ServerName directive sets the request scheme, hostname and port that 
    # the server uses to identify itself. This is used when creating 
    # redirection URLs. In the context of virtual hosts, the ServerName 
    # specifies what hostname must appear in the request's Host: header to 
    # match this virtual host. For the default virtual host (this file) this 
    # value is not decisive as it is used as a last resort host regardless. 
    # However, you must set it for any further virtual host explicitly. 
    #ServerName www.example.com 
    ServerName project1.webdev.com 
    ServerAdmin [email protected] 
    DocumentRoot "/var/www/html/project1/web" 

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 
    # error, crit, alert, emerg. 
    # It is also possible to configure the loglevel for particular 
    # modules, e.g. 
    #LogLevel info ssl:warn 

    ErrorLog ${APACHE_LOG_DIR}/project1-error.log 
    CustomLog ${APACHE_LOG_DIR}/project1-access.log combined 

    # For most configuration files from conf-available/, which are 
    # enabled or disabled at a global level, it is possible to 
    # include a line for only one particular virtual host. For example the 
    # following line enables the CGI configuration for this host only 
    # after it has been globally disabled with "a2disconf". 
    #Include conf-available/serve-cgi-bin.conf 
</VirtualHost> 

如果您有多个DNS,只需创建另一个端口80实例并路由到项目。

确保HostGator中的域名与您在虚拟主机中创建的ServerName匹配。