我有一个 AWS EC2 服务器,其网站指向 5 个不同的子域。 CodeIgniter 3.x php 上有 3 个子域。 1 使用 Laravel 5.6 php,1 使用 React JS。为所有这些网站配置了通配符 SSL。
其中一些预计每 2-3 个月会收到几周的巨大流量,这会提示您通过添加额外的服务器来配置负载均衡器来平衡负载。
让我们给他们起个名字吧
ci1.example.com
,ci2.example.com
,ci3.example.com
lv.example.com
reactapp.example.com
预计
reactapp.example.com
的交通量与 lv.example.com
相关。
httpd.conf
条目是这样的。
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/ci1/
ServerName ci1.example.com
CustomLog "/var/log/httpd/ci1_access.log" combined
ErrorLog "/var/log/httpd/ci1_error.log"
RewriteEngine on
RewriteCond %{SERVER_NAME} =ci1.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
存在子域
ci2
、ci3
、lv
和 reactapp
的类似条目。
顺便说一句,我尝试删除
ServerName
指令并更改 port to 443
。另外,尝试只保留一个VirtualHost
,如下所示,只是为了看看我是否可以至少在一个子域中实现它。
<VirtualHost *:443>
DocumentRoot /var/www/html/reactapp/
<Directory /var/www/html/reactapp/>
Options +Indexes
AllowOverride All
</Directory>
CustomLog "/var/log/httpd/reactapp_access.log" combined
ErrorLog "/var/log/httpd/reactapp_error.log"
</VirtualHost>
到目前为止,还没有运气。始终显示空白页,没有错误日志。如果添加
ServerName
指令,该站点就会出现。但是,httpd
访问日志正在填充到添加到目标组的所有服务器中。
如有任何建议,我们将不胜感激。
假设您的所有请求都来自同一个地址,您可以在
VirtualHost
中添加 ServerAlias
参数(您可以为同一虚拟主机定义多个),这样负载均衡器将重定向到同一地址,服务器可以回答。