I'm running an Apache2 setup, and it seems that everything I put inside the <VirtualHost *:443> tag gets completely ignored in the customconf.conf which is located at /etc/apache2/sites-available/customconf.conf file. However everything inside <VirtualHost *:80> works fine.

I've tried everything from a ProxyPass to trying to setup an ErrorDocument or even a Redirection, and no matter what is inserted inside the tag, nothing happens at all.

Here is my customconf.conf file:

<VirtualHost *:80>
    ServerName domain.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =domain.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

<VirtualHost *:443>
    ServerName domain.com
    DocumentRoot /var/www/html
    RedirectPermanent / https://google.com/

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem

    # Rest of your site config
    # ...

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Is there something I'm missing?

Edit: It does appear that when typing something completely incorrect, like just a random sequence of characters, restarting Apache will cause an error. But apart from that nothing else enclosed inside the VirtualHost tag appears to do anything.

  • Why do you say it doesn't appear to do anything? – Michael Hampton Oct 16 at 21:25
  • @MichaelHampton It's my understanding that if the VirtualHost was working properly then the site redirection would have been invoked when on port 443, the same way the redirection to https occurs on the VirtualHost *80 tag. – dm811 Oct 16 at 21:37
  • OK, so what actually does happen? – Michael Hampton Oct 16 at 21:47
  • The issue is that nothing actually does happen. My end goal here is to setup a ProxyPassReverse so that I can serve an Express application running on port 3000 on Apache on port 443. But considering that I've tried everything I can think of to try and get the ProxyPassReverse working, I'm left thinking that maybe the VirtualHost tag itself isn't functioning properly. – dm811 Oct 16 at 21:58
  • Nothing only would happen if you didn't actually try to load the web page. Something happened. What was it? – Michael Hampton Oct 16 at 22:33

Whilst I still haven't proven if <VirtualHost *:443> is actually working properly or not, I did still manage to solve the problem I was having by inserting my configuration for <VirtualHost *:443> outside of the tag. Maybe not a solution to my original question, but that's irrelevant now considering my ProxyPassReverse now works properly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.