Apache VirtualHostconfiguration将不会匹配

我有以下configuration,清漆作为外部端点(NGINX)和Apache之间的caching。

+-------+ +-------+ +------+ | NGINX | +---> |Varnish| +---> |Apache| +-------+ +-------+ +------+ 

当我从浏览器调用Apache VirtualHostconfiguration时,无法使其匹配。 我的(单个)VirtualHost的configuration如下所示:

 <VirtualHost *:80> ServerName fabrikam.com ServerAlias fabrikam.com ServerAdmin myemailaddress DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access-mycustomlog.log combined </VirtualHost> 

这里是Apache版本:

 root@localhost:/etc/apache2# apache2 -v Server version: Apache/2.4.7 (Ubuntu) Server built: Jan 14 2016 17:45:23 

症状

当我访问https://fabrikam.com ,它不会给我/var/www/html文件夹的根目录。 相反,它试图访问/var/www的根目录,因为我禁用了mod_index ,它给了我一个HTTP 404 Not Found错误。

有关如何让这个VirtualHostconfiguration“正确匹配”的任何想法? 当我访问fabrikam.com时,应该进入/var/www/html文件夹,而不是/var/www apache2.conf文件中的/var/www

编辑

这是apachectl -S的输出

 root@localhost:/etc/apache2# apachectl -S VirtualHost configuration: *:80 fabrikam.com (/etc/apache2/sites-enabled/000-default.conf:1) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www" Main ErrorLog: "/var/log/apache2/error.log" Mutex default: dir="/var/lock/apache2" mechanism=fcntl Mutex mpm-accept: using_defaults Mutex watchdog-callback: using_defaults PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 Group: name="www-data" id=33 

NGINXconfiguration

 ### Rewrite non-HTTPS URLs to HTTPS server { listen 80; server_name fabrikam.com; rewrite ^ https://$server_name$request_uri?; } server { listen 443 ssl; server_name fabrikam.com; ssl_certificate /etc/letsencrypt/live/fabrikam.com/cert.pem; ssl_certificate_key /etc/letsencrypt/live/fabrikam.com/privkey.pem; location / { proxy_pass http://127.0.0.1:6081; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Port 443; proxy_set_header Host $host; } } 

确保Apache被正确的实例/端口命中,而且Host标头正确地通过中间层转发。