Application error passthru when using apache mod_proxy

断了今生、忘了曾经 提交于 2021-02-10 06:14:41

问题


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


回答1:


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).

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.




回答2:


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):

<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>


来源:https://stackoverflow.com/questions/2531895/application-error-passthru-when-using-apache-mod-proxy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!