使用 apache mod_proxy 时的应用程序错误 passthru
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2531895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Application error passthru when using apache mod_proxy
提问by Andrew Taylor
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.
嘿嘿。我将 mod_proxy 与 apache2 一起使用,为在本地计算机上运行的多个 servlet 应用程序提供 vhost 功能。在大多数情况下,它运行良好。请求进入 apache,然后被定向到绑定在本地主机端口上的应用程序。应用程序接收请求并作出响应,由 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.
我遇到的问题是应用程序提供了 500 个错误,并且 mod_proxy 踩踏它们。通常这些错误是在 ajax 请求中引起的,并且错误是在客户端 javascript 中处理的。例如,对服务器端 createObject(name) 的调用可能会抛出 NameNotUniqueException ,它会作为 500 返回。然后客户端 javascript 可能会显示适当的错误消息。
When an error is thrown by the application (resulting in a 500 response to mod_proxy), then apache stomps the error message and returns
当应用程序抛出错误时(导致对 mod_proxy 的 500 响应),然后 apache 踩踏错误消息并返回
500 Internal Server Error
500内部服务器错误
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.
..股票apache服务器端错误消息。
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?
我希望 mod_proxy 将原始 500 传递回客户端。有没有我错过的指令可以防止 500 的破坏?
TIA
TIA
回答by Janning
Do you have
你有
ProxyRequests Off
ProxyErrorOverride Off
ProxyPass /path/ http://backend.ip/path/
ProxyPassReverse / http://backend.domain/
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).
将 backend.ip 和 backend.domain 替换为您的值(我在这里使用 backend.ip,因为它会阻止 apache 对每个请求运行 dns 查询)。
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.
通常错误按原样报告。因为 ProxyErrorOverride 默认为关闭。如果我的配置没有发生这种情况,请检查 500 是否真的来自您的后端服务器。或者只是向我们展示您的完整代理配置。
回答by mick88
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.
我有同样的问题,自从使用反向代理从 apache2/mod_wsgi 更改为 apache2 到 mod_wsgi-express 以来,得到了一个空白的 500 页。
My config (replaced actual domain with www.example.com):
我的配置(用 www.example.com 替换了实际域):
<VirtualHost *:443>
ServerName www.example.com
ProxyRequests Off
ProxyErrorOverride Off
ProxyPass / http://localhost:8001/
ProxyPassReverse / https://www.example.com/
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https"
ErrorLog /var/log/apache2/www.example.com.error.log
LogLevel warn
CustomLog /var/log/apache2/www.example.com.log combined
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/www.example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/www.example.com/fullchain.pem
</VirtualHost>

