I have an Elastic Beanstalk server which I am using for my employer's main site, example.com and they want me to host one of their ancillary sites on it: go.example.com.
So I just created a new ebextension config to create a second vhost. The problem I found is that Apache (HTTPD) only wants to use the first vhost entry.
Here are my vhosts:
# I have Apache listening on port 8080 because I have varnish in front of my sites.
<VirtualHost *:8080>
ServerName example.com
ServerAlias www.example.com
ServerAdmin [email protected]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ http://www.example.com%{REQUEST_URI} [R=301,L]
DocumentRoot "/var/app/current/httpdocs"
<Directory "/var/app/current">
AllowOverride All
Require all granted
</Directory>
<Directory "/var/app/current/cgi-bin">
AllowOverride All
Options None
Require all granted
</Directory>
<Directory "/var/app/current/httpdocs">
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.html index.php
Require all granted
</Directory>
</VirtualHost>
#go.example.com
<VirtualHost *:8080>
ServerName go.example.com
ServerAlias staging.go.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/go.example.com/httpdocs
<Directory "/var/www/go.example.com">
AllowOverride All
Require all granted
</Directory>
<Directory "/var/www/go.example.com/httpdocs">
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.html index.php
Require all granted
</Directory>
So the server will always listen for example.com, and with the above vhost order example.com will serve /var/app/current/httpdocs
while go.example.com is just a blank page.
If I swap the vhost order, so go.example.com is first, then example.com serves /var/www/go.example.com/httpdocs
. And go.example.com is still a blank page.
Nothing is really jumping out at me, and I dont have this problem is I build a regular ol' EC2.
Change:
To:
See the explanation here: https://serverfault.com/a/497075/164840
It looks as though your missing:
at the end of the file you pasted to close that vhost off. Also make sure that your sites-enabled has info on your new vhost in it.