简体   繁体   English

多个apache2虚拟主机位址-除一项外所有工作

[英]Multiple apache2 Virtual host sitses - All work except one

I have a problem with apache2 and Virtual Hosts. 我对apache2和虚拟主机有问题。 I run a server with multiple sites. 我运行的服务器上有多个站点。 I have subdomains setup that point to my server IP. 我有指向我的服务器IP的子域设置。 My customers, those that choose to have their own domain names point their domain/sub-domain to one of my subdomains. 我的客户(那些选择拥有自己的域名的客户)将其域/子域指向我的一个子域。 I've done this with multiple sites and it's always worked, except for now, and I cant figure out why. 我已经在多个网站上做到了这一点,并且除了现在,它一直都可以工作,我不知道为什么。 This is the virtual host that doesnt seem to work, it always points to my default site when i try to access it. 这是虚拟主机,似乎不起作用,当我尝试访问它时,它始终指向我的默认站点。

The domain redirecting goes like this. 域重定向是这样的。 customer.domain.com -> customer.mydomain.com -> server IP customer.domain.com-> customer.mydomain.com->服务器IP

<VirtualHost customer.domain.com:443>
    ServerName customer.domain.com
    ServerAlias *customer.domain.com *customer.mydomain.com
    DocumentRoot /var/www/page

  <Directory />
    Order Deny,Allow
    Deny from all
  </Directory>

  <Directory /var/www/page>
    Options -Indexes +FollowSymLinks +MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
  ErrorLog /var/log/apache2/customer/logs/error.log

  LogLevel warn

  CustomLog /var/log/apache2/customer/logs/access.log combined

  SSLEngine on
  SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key


  BrowserMatch ".*MSIE.*" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0
</VirtualHost>

This format is used for all other sites, and they are directed to the correct folder and site. 此格式用于所有其他站点,它们被定向到正确的文件夹和站点。 But with this particular site it always gets directed to the default site. 但是对于这个特定的站点,它总是被定向到默认站点。

I've noticed that when i run apache2ctl -SI get two IPs. 我注意到,当我运行apache2ctl -SI时,会获得两个IP。 One is my servers IP with all of the virtual hosts, and the second IP seems connected to the new virtual host, the one that doesnt work. 第一个是我具有所有虚拟主机的服务器IP,第二个IP似乎已连接到新的虚拟主机,一个无效。

52.52.52.52:443       customer.domain.com (/etc/apache2/sites-enabled/006-customer.domain.com.conf:1)
12.12.12.12:443       is a NameVirtualHost
         default server default.mydomain.com (/etc/apache2/sites-enabled/001-default.mydomain.com.conf:1)
         port 443 namevhost default.mydomain.com (/etc/apache2/sites-enabled/001-default.mydomain.com.conf:1)
                 alias www.default.mydomain.com
         port 443 namevhost customer2.domain.com (/etc/apache2/sites-enabled/002-customer2.domain.com.conf:1)
                 alias www.customer2.domain.com
                 wild alias *subdomain.mydomain.com
*:80                   default.mydomain.com (/etc/apache2/sites-enabled/000-default.conf:1) ..... more 

I'm not really sure what to look for, the logs don't seem to tell me anything useful. 我不确定要查找的内容,日志似乎没有告诉我任何有用的信息。

Any ideas on what I might be doing wrong? 关于我可能做错了什么的任何想法? Thank you. 谢谢。

You should avoid putting hostnames inside of <virtualhost> at all costs. 您应该不惜一切代价避免将主机名放在<virtualhost>中。 On a typical system, *:port in each vhost is sufficient. 在典型的系统上,每个虚拟主机中的*:port就足够了。

If you really care about what local interface a connection is related to BEFORE checking the hostname used, put a local interface address name and not a hostname. 如果在检查使用的主机名之前确实关心连接与哪个本地接口相关,请放置本地接口地址名称而不是主机名。 But most people simply do not care what interface was used. 但是大多数人根本不在乎使用了什么接口。

The particular risk of using a hostname is that it might not resolve to any local interface, in which case Apache will never map a connection to it. 使用主机名的特殊风险是它可能无法解析为任何本地接口,在这种情况下,Apache永远不会将连接映射到该主机名。 The per-request hostname matching only kicks in from the best matching connection-level info. 每个请求的主机名匹配仅从最匹配的连接级别信息开始。

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

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