PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, June 24, 2022

[FIXED] How to configure Apache ProxyPass and ProxyReverse for dotnet C# MVC routing in order to get exception for .well-known

 June 24, 2022     apache, apache2, asp.net, regex, reverse-proxy     No comments   

Issue

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!


Solution

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>


Answered By - Leandro Bardelli
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing