I have the following configuration, with Varnish acting as a cache between the externally facing endpoint (NGINX) and Apache.
+-------+ +-------+ +------+
| NGINX | +---> |Varnish| +---> |Apache|
+-------+ +-------+ +------+
I can't get my Apache VirtualHost configuration to match, when I call it from a browser. The configuration for my (single) VirtualHost looks like this:
<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>
Here's the Apache version:
root@localhost:/etc/apache2# apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jan 14 2016 17:45:23
Symptom
When I access https://fabrikam.com
, it doesn't give me the root of the /var/www/html
folder. Instead, it tries to access the root of /var/www
, and because I disabled mod_index
, it gives me a HTTP 404 Not Found error.
Any thoughts on how to get this VirtualHost configuration to "match" properly? When I access fabrikam.com, it should go to the /var/www/html
folder, instead of /var/www
in the apache2.conf
file.
EDIT
Here's the output from 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
NGINX Configuration
### 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;
}
}
Make sure that Apache is hit on the correct instance/port and with the Host header correctly forwarded through the middle tiers.