首页 > 解决方案 > 单个域的多个 IP

问题描述

我正在托管具有相同域和子域的多个应用程序。让我们同意有 3 个应用程序具有这些服务器配置和一个 mywebsite.com 域

server1 ip is 123.234.345.23 ,and the app is located on app.mywebsite.com
server2 ip is 12.222.88.222 ,and the app is located on test.mywebsite.com
server1 ip is 123.123.123.23 ,and the app is located on mywebsite.com

我像这样在 3 台服务器上创建了一个虚拟主机配置

<VirtualHost *:80>
    ServerAdmin contacts@myemail.com
    ServerName mywebsite.com
    ServerAlias www.mywebsite.com
    DocumentRoot /var/www/html/mywebsite
    <Directory /var/www/html/mywebsite>
         Options Indexes FollowSymLinks
         AllowOverride All
         Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/mywebsite.com_error.log 
    CustomLog ${APACHE_LOG_DIR}/mywebsite.com_access.log combined 
</VirtualHost>

我已经使用域的 DNS 配置了 3 个 IP 地址。server1 dns

Type: A, Name: @, Value: 123.234.345.23
Type: A, Name: *, Value: 123.234.345.23

server2 dns

Type: A, Name: @, Value: 12.222.88.222
Type: A, Name: *, Value: 12.222.88.222

server3 dns

Type: A, Name: @, Value: 123.123.123.23
Type: A, Name: *, Value: 123.123.123.23

当我尝试访问 server2 和 server3 时,它总是将我重定向到 server1。我该如何解决这个问题?请注意,我没有进行负载平衡,它只是根据需要进行重定向。

标签: apacheubuntudnsip-addressvirtualhost

解决方案


推荐阅读