I'm trying to setup my application using HTTPs, I followed a guide HERE to do it properly but it's not working.

My app runs perfectly in port 80 (http) and when I turn on auto redirect for 443 (https) it gives me a 403 forbiddend when I try to access it through Browser. And in Apache2 error log, I can see the message "AH01276: Cannot serve directory /var/my_app_location/: No matching DirectoryIndex"

The differences between conf files from 80 to 443 are basically:

  • Port number

  • Present in 443 file config:

    • "IfModule mod_ssl.c" present in 443 file config
    • Include letsencrypt
    • SSLCertificateFile
    • SSLCertificateKeyFile
    • <Directory "/var/my_app_location/">AllowOverride none Require all granted

Can anyone guide me?

UPDATE Here is the virtualhost files:

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName mydomain.com.br
ServerAlias www.mydomain.com.br
DocumentRoot /var/netcore/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine off
RewriteCond %{SERVER_NAME} =www.mydomain.com.br [OR]
RewriteCond %{SERVER_NAME} =mydomain.com.br
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI}[END,NE,R=permanent]

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName www.mydomain.com.br
    ServerAlias *.mydomain.com.br
    DocumentRoot /var/netcore/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory "/var/netcore">
        AllowOverride none
        Require all granted

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.com.br/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com.br/privkey.pem
  • 2
    Show the actual VirtualHost for each port. May 1, 2023 at 20:32
  • I followed a guide either the guide is broken, or you didn't follow it correctly May 2, 2023 at 4:31
  • I am sorry, what link did you provide? All details must be included in your post. Links break, change and can be deleted. Put everything required in your post. May 2, 2023 at 5:15
  • @JaromandaX Sorry, now I provided the link.
    – mfvjunior
    May 2, 2023 at 12:28
  • @JohnHanley Now I provided the guide that I followed.
    – mfvjunior
    May 2, 2023 at 12:29

1 Answer 1


Solved. For Http, there was another complementary configuration (/etc/apache2/conf-enabled) that turned on a reverse proxy that redirects traffic to the running local service (net core app).

The solution was including this reverse proxy config also for the 443 virtual host file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .