【发布时间】:2018-08-27 07:53:42
【问题描述】:
我在将 Apache 设置为我的 Express/Node 应用程序的反向代理时遇到问题。可以通过正确的 URL 访问应用程序,但找不到带有 Express 参数的路由 404。
这是我的 server.js 路由配置:
app.get('/quiver/note/:path', (req, res, next) => {
const note = getQuiverNote(req.params.path)
res.json(note)
})
这里是我用于反向代理的 Apache conf:
<VirtualHost *:80>
ServerName quiver-node-reader.local
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
ErrorLog "/var/log/httpd/quiver-node-reader.local-error_log"
CustomLog "/var/log/httpd/quiver-node-reader.local-access_log" common
<Proxy *>
#Require all granted
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://127.0.0.1:8080/
ProxyPassReverse http://127.0.0.1:8080/
</Location>
</VirtualHost>
当我使用 http://127.0.0.1:8080 浏览我的应用程序时,一切正常。 当我通过 Apache 使用 http://quiver-node-reader.local 浏览我的应用程序时,我可以毫无问题地访问我的应用程序,但是当调用带有参数的路由时,这次我得到了 404 :(
示例: http://quiver-node-reader.local/quiver/note/data%2Fformat-z%20(dev).qvnotebook%2FC9EBA21F-D425-4C99-BCAB-8B7B20235FF0.qvnote -> 此路线无法到达 404 错误 http://127.0.0.1:8080/quiver/note/data%2Fformat-z%20(dev).qvnotebook%2FC9EBA21F-D425-4C99-BCAB-8B7B20235FF0.qvnote -> 可以联系到
这是来自 Apache 的日志:
127.0.0.1 - - [27/Aug/2018:09:48:25 +0200] "GET /quiver/note/data%2Fformat-z%20(dev).qvnotebook%2FC9EBA21F-D425-4C99-BCAB -8B7B20235FF0.qvnote HTTP/1.1" 404 75
【问题讨论】:
标签: node.js apache express reverse-proxy