Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache and mod_proxy not handling HTTP 100-continue from client HTTP 417

Tags:

proxy

apache

'm building some webby magic and am using Apache to front our tomcat server, forwarding requests to tomcat on port 8080. I have an issue using Apache and mod_proxy to forward requests. It appears the client (a web application) sends an HTTP 100-continue to which Apache responds with a 417 Expectation Failed.

When I take Apache out of the picture and send requests directly to tomcat on port 8080, the request is successful and the client is sent a 200 OK.

My Apache config looks like:

ServerName abcproxy DocumentRoot /apps/apache-content/default

AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript text/xml

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

ExpiresActive on
ExpiresDefault "access 0 seconds"

ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/

        ProxyPreserveHost On

CustomLog /apps/ocp-logs/apache/abcproxy.log combined

Anyone see where i'm going wrong?

like image 266
DrPep Avatar asked Oct 08 '10 10:10

DrPep


People also ask

What is mod_proxy in Apache?

mod_proxy is an optional module for the Apache HTTP Server. This module implements a proxy, gateway or cache for Apache. It implements proxying capability for AJP13 (Apache JServ Protocol version 1.3), FTP, CONNECT (for SSL), HTTP/0.9, HTTP/1.0, and (since Apache 1.3. 23) HTTP/1.1.

What is expect 100 continue?

The client will expect to receive a 100-Continue response from the server to indicate that the client should send the data to be posted. This mechanism allows clients to avoid sending large amounts of data over the network when the server, based on the request headers, intends to reject the request.

What is ProxyPass and ProxyPassReverse in Apache?

The "ProxyPass" and "ProxyPassReverse" parameters are used to tell Apache how to proxy requests. They require the "mod_proxy.so" and "mod_proxy_http.so" Apache modules, which are loaded by default in RHEL5 and RHEL6, but check the following lines are uncommented in the "/etc/httpd/conf/httpd. conf" file to make sure.

What is ProxyPreserveHost?

The ProxyPreserveHost directive is used to instruct Apache mod_proxy, when acting as a reverse proxy, to preserve and retain the original Host: header from the client browser when constructing the proxied request to send to the target server.


1 Answers

Apache has a known and unresolved issue with Expect headers, see bug 46709 and bug 47087.

The issue is that some clients set the Expect header and only send the request headers before a PUT or POST of data. This allows the server to respond to errors/redirects/security violations prior to the client sending the request body (PUT or POST data). This is a laudable goal, but apparently, the client does not wait until it gets a response and just pushes out the body of the request, which results in the 417 error.

If you have control over a .NET client you can use ServicePointManager.Expect100Continue Property set to false, to override this behavior.

If you only have control over the server, it looks like you can either force HTTP 1.0 for those clients (perhaps based on user agent string) or force unset the Expect header using mod_header early on in the request.

To remove the Expect header from the request early using mod_headers use this config directive:

<IfModule mod_headers.c>
RequestHeader unset Expect early
</IfModule>

This works because the client is not actually waiting for the "100 Continue" response and acting as if the Expect header were not set.

like image 191
lambacck Avatar answered Sep 18 '22 00:09

lambacck