Apache 多个 IP 和虚拟主机

Apache 多个 IP 和虚拟主机

我有两个可以在 linode 上使用的 IP,我在服务器上运行着三个网站,它们都在不同的域名上,其中两个也在 SSL 上运行

以下是我的 httpd.conf 的相关部分(在 CentOS 6.2 上运行 Apache2):

NameVirtualHost 178.79.165.220:80
NameVirtualHost 176.58.116.80:80
NameVirtualHost 176.58.116.80:443
NameVirtualHost 178.79.165.220:443


<VirtualHost 178.79.165.220:80>
  ServerAdmin [email protected]
  ServerName  domain3.com
  ServerAlias www.domain3.com
  DirectoryIndex index.php
  DocumentRoot /var/www/domain3.com/public_html/
  LogLevel warn
  ErrorLog  /var/www/domain3.com/logs/error.log
  CustomLog /var/www/domain3.com/logs/access.log combined
</VirtualHost>

<VirtualHost 178.79.165.220:80>
  ServerAdmin [email protected]
  ServerName  domain1.com
  ServerAlias www.domain1.com
  DirectoryIndex index.php
  DocumentRoot /var/www/domain1.com/public_html/
  LogLevel warn
  ErrorLog  /var/www/domain1.com/logs/error.log
  CustomLog /var/www/domain1.com/logs/access.log combined
</VirtualHost>

<VirtualHost 178.79.165.220:443>
  ServerAdmin [email protected]
  ServerName  domain1.com
  ServerAlias www.domain1.com
  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/domain1.com/domain1.com.crt
  SSLCertificateKeyFile /etc/ssl/certs/domain1.com/domain1.com.key
  SSLCertificateChainFile /etc/ssl/certs/domain1.com/domain1.com.bundle.crt

  DirectoryIndex index.php
  DocumentRoot /var/www/domain1.com/public_html/
  LogLevel warn
  ErrorLog  /var/www/domain1.com/logs/error.log
  CustomLog /var/www/domain1.com/logs/access.log combined
</VirtualHost>

<VirtualHost 176.58.116.80:80>
  ServerAdmin [email protected]
  ServerName  domain2.com
  ServerAlias www.domain2.com
  DirectoryIndex index.php
  DocumentRoot /var/www/domain2.com/public_html/
  LogLevel warn
  ErrorLog  /var/www/domain2.com/logs/error.log
  CustomLog /var/www/domain2.com/logs/access.log combined
</VirtualHost>

<VirtualHost 176.58.116.80:443>
  ServerAdmin [email protected]
  ServerName  domain2.com
  ServerAlias www.domain2.com
  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/sba/sba.crt
  SSLCertificateKeyFile /etc/ssl/certs/sba/sba.key
  SSLCertificateChainFile /etc/ssl/certs/sba/sba-bundle.crt

  DirectoryIndex index.php
  DocumentRoot /var/www/domain2.com/public_html/
  LogLevel warn
  ErrorLog  /var/www/domain2.com/logs/error.log
  CustomLog /var/www/domain2.com/logs/access.log combined
</VirtualHost>

问题是,如果您进入域 3,您基本上会因为某种原因进入域 1。

答案1

尝试添加

NameVirtualHost 178.79.165.220:80

到配置。您当前有,这与 domain1.com 和 domain3.com 之间共享的套接字NameVirtualHost *:80无关。178.79.165.220:80

相关内容