title: Virtualhost subdomain not working on AWS EC2
body: <p>I'm trying to configure a reverse proxy on an AWS EC2 instance using XAMPP.</p>
  
  <p>My httpd-vhosts.conf works fine from localhost, but not from my EC2 server:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
    ProxyPreserveHost On
    ProxyRequests Off
    ServerName ec2-foo.us-east-2.compute.amazonaws.com
    ServerAlias ec2-foo.us-east-2.compute.amazonaws.com
    DocumentRoot "/opt/lampp/htdocs/main"
  &lt;/VirtualHost&gt;
  &lt;VirtualHost *:80&gt;
    ProxyPreserveHost On
    ProxyRequests Off
    ServerName bar.ec2-foo.us-east-2.compute.amazonaws.com
    ProxyPass / http://example.com
    ProxyPassReverse / http://example.com
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>There is no error when I access <code>bar.localhost</code>, but there is when I access it from <code>bar.ec2-foo.us-east-2.compute.amazonaws.com</code>.</p>
  
  <p>Is there a way to fix this? If not, is there a way to access <code>example.com</code> via <code>ec2-foo.us-east-2.compute.amazonaws.com/bar</code>?</p>