3
votes

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

2
What about using mod_proxy_ajp or mod_jk? Seems to me they are more tailored to connecting Apache to servlets. - Jackson Miller
good suggestion. The app is a standalone jetty powered dyn web engine. Perhaps I should look at jetty ajp connections. - Andrew Taylor
Hmm, mod_proxy seems to be the preferred method (docs.codehaus.org/display/JETTY/Configuring+AJP13+Using+mod_jk). As such, I'm surprised I've found no solution for this issue. - Andrew Taylor

2 Answers

3
votes

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.

0
votes

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>