Score:0

Ubuntu - Issue hosting (HTTPS only) a Net core app: "AH01276 - Cannot serve directory"

nu flag

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]
</VirtualHost>



<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
    </Directory>


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
</VirtualHost>
</IfModule>
John Hanley avatar
cn flag
Show the actual VirtualHost for each port.
Jaromanda X avatar
ru flag
`I followed a guide` either the guide is broken, or you didn't follow it correctly
John Hanley avatar
cn flag
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.
mfvjunior avatar
nu flag
@JaromandaX Sorry, now I provided the link.
mfvjunior avatar
nu flag
@JohnHanley Now I provided the guide that I followed.
in flag
Links to tutorials are useless. We have no way of knowing which steps you followed and which not. We don't know how the config looked in the first place. Provide your actual configuration files.
mfvjunior avatar
nu flag
@GeraldSchneider exactly, I didn't expect that the guide would be relevant, but they asked. I wasn't connected to the machine to provide the full file config, so I tried to resume in description. Now it is updated.
in flag
Where is the global definition of `DirectoryIndex` in your apache config?
mfvjunior avatar
nu flag
I think I don't have one, I think I shouldn't have one. I'm running a net core app, usually we don't have a index.html file when publish. In the apache.conf file it doesn't list a directoryindex as well.. As I said previously, http works fine without this directoryindex.
Score:0
nu flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.