I've a site in ASP.NET MVC Core 3.1 C#
running over a Debian
with Apache 2
trought a ProxyPass
and ProxyReverse
and a functional domain and SSL Let's Encrypt certificate with the following configuration in a site-com.conf
file:
ProxyPreserveHost On
ProxyPass / https://localhost:1234/
ProxyPassReverse / https://localhost:1234/
ProxyPassMatch ^/.well-known !
So far so good, this works fine. But every time I need to update my certificates and I have to change the configuration to <Directory>
in order the certbot can find the .well-know
directory. This is not a problem but the site for this lapse is offline and I can't automate the process.
So I researched in Server Fault
and Stack Overflow
several solutions, nothing works. The more close solution is on this: Exclude an alias from virtualhost proxypass
But I can't manage to made it work. Last attempt with this configuration:
ProxyPreserveHost On
ProxyPass / https://localhost:1234/
ProxyPassReverse / https://localhost:1234/
ProxyPassMatch ^/.well-known !
Alias /.well-known "/www/example.com/public_html/.well-known"
<Directory "/www/example.com/public_html/.well-known" >
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
The url example.com/.well-known/acme-challenge/file
is catched by the MVC Routing.
I also created a index.html
file to check the URL example.com/.well-known/acme-challenge/index.html
but happens the same.
How can I configure this?
I'm testing the RegEx now meanwhile we talk, but IDK where to begin to fix this.
Yes, I restart and reload the server everytime I do a change.
If you need more information or settings from my conf file, please ask me for them in the config. Thanks in advance for tips and helps!
CodePudding user response:
I finally success. There were two problems: 1) It works better with ProxyPass precedence
AND the Allow
was not correct.
For this configuration it works:
ProxyPreserveHost On
ProxyPass /.well-known !
ProxyPass / https://localhost:1234/
ProxyPassReverse / https://localhost:1234/
Alias /.well-known "/example.com/public_html/.well-known"
<Directory "/example.com/public_html/.well-known" >
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>