node.js - Apache Location 正则表达式不匹配路径

标签 node.js apache express routes

我只是试图通过更改虚拟主机设置以使用代理设置来将我的 apache 服务器指向 node.js 应用程序,并且当我尝试使 block 通过它匹配所有位置时,它仅匹配具有 1 级深度 url 路径的 url。/example 有效,但/example/damn 不起作用。所以我尝试将正则表达式更改为 Which 甚至有点过分,但我想我会尝试一下,我一直在尝试很多其他正则表达式组合,但没有一个捕获 URL。我可能会补充一点,上面的正则表达式实际上根本不捕获任何内容,它只是在我获取网址时显示我的网站的索引列表。唯一有效的正则表达式是“/*”,但它的深度不会超过 1 个 url/path/anotherpath

我检查了我的正则表达式应该匹配 https://regex101.com/ 处的所有内容但 apache 仍然没有捕获它。

这是我的配置

<VirtualHost *:80>

        ServerName my.dev
        ServerAdmin ireply@myleisure.com.au
        DocumentRoot /home/ggg/Dropbox/host-root/var/www/myleisure.com.au

        ProxyRequests Off
        ProxyPreserveHost On
        ProxyVia Full

        <Proxy "*">
                Require all granted
        </Proxy>

        <Location "(.*)*">
                ProxyPass http://localhost:3000
                ProxyPassReverse http://localhost:3000
        </Location>



</VirtualHost>

最佳答案

这里引用了 Apache 指令配置 documentation page

The directive limits the scope of the enclosed directives by URL, in an identical manner to . However, it takes a regular expression as an argument instead of a simple string.

因此,请尝试使用:

<LocationMatch "(.*)*">
        ProxyPass http://localhost:3000
        ProxyPassReverse http://localhost:3000
</LocationMatch>

关于node.js - Apache Location 正则表达式不匹配路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43336606/

相关文章:

node.js - 使用 Node.js 对 s3 存储桶进行 api 调用时访问被拒绝

php - 404 htaccess clean url 错误

javascript - Node JS : Listening for HTTPS POST JSON Requests

debugging - Node.js Express Mongoose 查询查找

javascript - 如何使用 chai 和 sinon 测试方法是否重新抛出现有错误

node.js\为什么我会收到 RangeError : Maximum call stack size exceeded

java - 使用 Apache Maths (Java) 的多项式回归强制在 (0,0) 处截距

linux - svn: E000002: 无法打开请求的 SVN 文件系统

node.js - res.json() 和 res.end() 之间的性能差异

node.js - 几个小时后 Puppeteer 变慢