Common complications

The web server should handle static files or some other subset of the URI space

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"""<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Hello</title>
    <link rel="stylesheet" href="/static/hello-static.css">
  </head>
  <body>
    <p>Hello World</p>
  </body>
</html>
"""]

httpd

The ProxyPass directive has a variation to disable proxy for certain requests — add an exclamation mark after the URI. Here's an example:

Listen 80
<VirtualHost *:80>
  <Location />
    ProxyPass unix:/tmp/hello-static-FastCGI.s|fcgi://127.0.0.1/
  </Location>
  <Location /static/>
    ProxyPass !
  </Location>
</VirtualHost>

In the example, files under path /static will be served by httpd. (They'll be searched for under DocumentRoot unless an Alias directive is used to map /static to another filesystem location.)

nginx

The try_files directive of nginx is commonly used for this purpose. Here's a complete example, in which the stylesheet referenced by the WSGI app will be served from /home/trawick/pyweb-install/nginx/htdocs/static/hello-static.css:

server {
    listen 80;
    root /home/trawick/pyweb-install/nginx/htdocs;

    location / {
        try_files $uri @appserver;
    }

    location @appserver {
        include fastcgi_params;
        fastcgi_pass unix:/tmp/hello-static-FastCGI.s;
    }
}

Web application is mounted somewhere strange in the web server space

E.g., the client requests http://www.example.com/myapp/ on the web server in order to get what the web application thinks is /.

TBD

Load balancing requirements

E.g., you need distinct sets of application processes running redundantly or with access to different pools of resources or ...

TBD (don't forget session stickyness)

Controlling pooling of connections

Connections to the application processes can be retained by web server processes for extra efficiency. But this isn't implemented for most of the combinations we've discussed. Of these, only the HTTP proxy with Apache httpd supports maintaining a pool of backend connections.

A more complex configuration for mod_proxy that maintains connections:

TBD

Controlling I/O parameters

TBD

Passing metadata from the web server to the application

With HTTP, the extra data will need to be sent in HTTP request header fields.

With FastCGI and SCGI, the extra data will need to be exposed via CGI-style environment variables.

Passing Basic auth to the application

TBD