【问题标题】:How to configure Apache ProxyPass and ProxyReverse for dotnet C# MVC routing in order to get exception for .well-known如何为 dotnet C# MVC 路由配置 Apache ProxyPass 和 ProxyReverse 以获得 .well-known 的异常
【发布时间】:2022-01-17 05:10:45
【问题描述】:

我在ASP.NET MVC Core 3.1 C# 中有一个站点,在Debian 上运行,Apache 2 通过ProxyPassProxyReverse 以及一个功能域和 SSL Let's Encrypt 证书在site-com.conf 文件中具有以下配置:

ProxyPreserveHost On
ProxyPass / https://localhost:1234/
ProxyPassReverse / https://localhost:1234/
ProxyPassMatch ^/.well-known !

到目前为止一切顺利,这工作正常。但是每次我需要更新我的证书时,我都必须将配置更改为 <Directory> 以便 certbot 可以找到 .well-know 目录。这不是问题,但这次失误的网站处于离线状态,我无法自动化该过程。

所以我研究了Server FaultStack Overflow 几种解决方案,没有任何效果。更接近的解决方案是:Exclude an alias from virtualhost proxypass

但我无法让它工作。使用此配置的最后一次尝试:

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>

网址example.com/.well-known/acme-challenge/fileMVC Routing. 捕获 我还创建了一个 index.html 文件来检查 URL example.com/.well-known/acme-challenge/index.html,但发生的情况相同。

我该如何配置?

我正在测试 RegEx,同时我们正在讨论,但是 IDK 从哪里开始解决这个问题。
是的,我每次进行更改时都会重新启动并重新加载服务器。

如果您需要我的 conf 文件中的更多信息或设置,请在配置中向我索取。提前感谢您的提示和帮助!

【问题讨论】:

    标签: asp.net regex apache apache2 reverse-proxy


    【解决方案1】:

    我终于成功了。有两个问题:1) 使用 ProxyPass precedence 效果更好,而 Allow 不正确。

    对于这个配置它有效:

    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>
    

    【讨论】:

      猜你喜欢
      • 2016-01-14
      • 2016-10-08
      • 2017-01-13
      • 1970-01-01
      • 2021-01-18
      • 1970-01-01
      • 2020-04-02
      • 2020-05-25
      • 1970-01-01
      相关资源
      最近更新 更多