title: Proxypass nodejs app on subdomain with Apache 2.4.29
body: <p>The app I'm using is <a href="https://github.com/WeebDev/lolisafe" rel="nofollow noreferrer">Lolisafe</a> and it opens a local port to 9999.</p>
  
  <p>For my domain, I need the regular website to work (<a href="https://example.com" rel="nofollow noreferrer">https://example.com</a>) but also have a subdomain (<a href="https://sub.example.com" rel="nofollow noreferrer">https://sub.example.com</a>) to link to the nodejs application which has a home.html page under <strong>/srv/http/lolisafe/pages/</strong>. Lolisafe also uses an API which calls under /api, so for example <a href="https://sub.example.com/api" rel="nofollow noreferrer">https://sub.example.com/api</a> is how logging in functions.</p>
  
  <p>All my domains files reside in /srv/http</p>
  
  <p>httpd.conf:</p>
  
  <pre><code>Include conf/extra/site/domain.conf
  Include conf/extra/site/lolisafe.conf
  </code></pre>
  
  <p>A Records are set for @, www, and lolisafe all with the same IP.</p>
  
  <p>Currently my /etc/httpd/conf/extra/site/domain.conf file contains this:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  ServerAdmin admin@example.com
  DocumentRoot "/srv/http/"
  
  ServerName example.com
  ServerAlias www.example.com
  
  ErrorLog "/var/log/httpd/example.com-error_log"
  CustomLog "/var/log/httpd/example.com-access_log" common
  Redirect permanent / https://example.com/
  
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:443&gt;
  ServerAdmin admin@example.com
  DocumentRoot "/srv/http/"
  
  ServerName domain.com
  ServerAlias www.domain.com
  
  ErrorLog "/var/log/httpd/example.com-error_log"
  CustomLog "/var/log/httpd/example.com-access_log" common
  
  SSLEngine on
  SSLCACertificateFile /etc/httpd/conf/ca_bundle.crt
  SSLCertificateFile /etc/httpd/conf/server.crt
  SSLCertificateKeyFile /etc/httpd/conf/server.key
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>And /etc/httpd/conf/extra/site/lolisafe.conf contains:</p>
  
  <pre><code>&lt;VirtualHost *:*&gt;
      ProxyPreserveHost On
      ServerName lolisafe.example.com
      DocumentRoot     "/srv/http/lolisafe/pages/"
      ProxyPass        "/" "http://0.0.0.0:9999/"
      ProxyPassReverse "/" "http://0.0.0.0:9999/"
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Currently with this setup, visiting <a href="https://sub.example.com" rel="nofollow noreferrer">https://sub.example.com</a> goes directly to <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a>. What am I doing wrong?</p>