0

I want to redirect a certain sub-path to a backend application running at port 19011. My config file (/etc/apache2/sites-available/my_domain.conf) looks like this:

<VirtualHost *:80>
    ServerName my_domain
    DocumentRoot /var/www/my_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ProxyPass /my_subpath/ http://localhost:19011/
    ProxyPassReverse /my_subpath/ http://localhost:19011/
</VirtualHost>

<VirtualHost *:443>
    SSLEngine On
    SSLProxyEngine On
    SSLCertificateFile /etc/letsencrypt/live/my_domain/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/my_domain/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
    
    ServerName my_domain
    DocumentRoot /var/www/my_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ProxyPass /my_subpath/ http://localhost:19011/
    ProxyPassReverse /my_subpath/ http://localhost:19011/
</VirtualHost>

This configuration works with HTTP, but not with HTTPS:

  • http://my_domain/my_subpath goes to the backend app as intended, whereas
  • https://my_domain/my_subpath returns 404

I am an apache noob, so I don't know why this doesn't work. I also don't see any errors in the apache logs. What am I missing in the conf file?

Versions:

  • Apache: 2.4.29
  • OS: Ubuntu 18.04.5
Egemen
  • 101
  • 1
  • 2

1 Answers1

0

It turned out there was nothing wrong with my conf file. There was another conf file named my_domain-le-ssl.conf under /etc/apache2/sites-available, which was created automatically after I had created the SSL certificate with Letsencrypt. That conf file also contained virtual host for port 443, and Apache was using that one to serve SSL requests.

When in doubt, execute sudo apachectl -S in order to see your active virtual host configuration. In my case, it returned something like this:

*:80 my_domain (/etc/apache2/sites-enabled/my_domain.conf:1)
*:443 my_domain (/etc/apache2/sites-enabled/my_domain-le-ssl.conf:2)
*:443 my_domain (/etc/apache2/sites-enabled/my_domain.conf:10)
Egemen
  • 101
  • 1
  • 2