使用 apache mod_proxy 时的应用程序错误通路
嘿嘿。我使用 mod_proxy 和 apache2 为本地计算机上运行的多个 servlet 应用程序提供虚拟主机功能。在大多数情况下,它工作得很好。请求进入 apache,然后被定向到绑定在本地主机端口上的应用程序。应用程序接收请求并响应,由 apache 传回客户端。
我遇到的问题是应用程序会在错误时发出 500 错误,而 mod_proxy 则会对其进行踩踏。通常这些错误是在 ajax 请求中引起的,并且错误在客户端 JavaScript 中处理。例如,对服务器端 createObject(name) 的调用可能会抛出 NameNotUniqueException ,该异常会以 500 的形式返回。然后,客户端 javascript 可能会显示相应的错误消息。
当应用程序抛出错误(导致对 mod_proxy 的 500 响应)时,apache 会停止该错误消息并返回
500 Internal Server Error
Internal Server Error
服务器遇到内部错误或 配置错误并且无法完成 您的要求。
.. 库存 apache 服务器端错误消息。
我希望 mod_proxy 将原始 500 传递回客户端。我是否遗漏了一条防止 500 被破坏的指令?
TIA
Heyas. I'm using mod_proxy with apache2 provide vhost ability to multiple servlet apps running on the local machine. It works fine, for the most part. Requests come into apache then are directed to the application bound on a port on localhost. The app receives the request and responds, which is delivered back to the client by apache.
The problem I'm having is that the application delivers 500's on errors, and mod_proxy stomps on them. Often these errors are caused in a ajax request and the error is handled in client side javascript. For example, a call to a server side createObject(name) might throw a NameNotUniqueException , which is delivered back as a 500. The client javascript might then display an appropriate error message.
When an error is thrown by the application (resulting in a 500 response to mod_proxy), then apache stomps the error message and returns
500 Internal Server Error
Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
.. the stock apache server side error message.
I want mod_proxy to pass the original 500 back through to the client. Is there a directive I've missed which prevents clobbering of the 500?
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否已将
backend.ip 和 backend.domain 替换为您的值(我在这里使用 backend.ip,因为它阻止 apache 对每个请求运行 dns 查询)。
通常错误会按原样报告。因为ProxyErrorOverride默认是关闭的。如果我的配置没有发生这种情况,请检查 500 是否确实来自您的后端服务器。或者只是向我们展示您完整的代理配置。
Do you have
Replace backend.ip and backend.domain with your values (i am using backend.ip here as it prevents apache from running dns queries on each request).
Usually errors are reported as is. Because ProxyErrorOverride defaults to off. If this doe not happen with my configuration, please check if the 500 is really from your backend server. Or just show us your complete proxy configuration.
我有同样的问题,自从从 apache2/mod_wsgi 更改为 apache2 并反向代理到 mod_wsgi-express 后,出现了 500 个空白页面。
我的配置(用 www.example.com 替换实际域):
I have the same problem, getting a blank 500 pages since changing from apache2/mod_wsgi to apache2 with reverse proxy to mod_wsgi-express.
My config (replaced actual domain with www.example.com):