I'm trying to set up a reverse proxy to CouchDB using Apache on an instance of Ubuntu Server 12.04. I have been accessing CouchDB directly through port 5984 but the lack of compression on responses is causing too much network usage, and the reverse proxy allows me to enable gzip compression.
So far, I've set the configuration file for my site as so:
# /etc/apache2/sites-available/SITE_NAME
<VirtualHost *:80>
ServerAdmin *****
ServerName *****
ServerAlias *****
RewriteEngine On
RewriteOptions Inherit
RewriteRule ^/couch/(.*) http://%{HTTP_HOST}:5984/$1 [P]
ProxyPass /couch/ http://localhost:5984/ nocanon
ProxyPassReverse /couch/ http://localhost:5984/
DocumentRoot /var/www/*****/current/public
<Directory /var/www/*****/current/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
At this point, I can access CouchDB through the reverse proxy using curl, e.g.
curl -X GET http://MY_SERVER_ADDRESS/couch/_all_dbs
and I get successful responses every time.
However, the primary client of this proxy is an iOS device, and whenever I run the same request using NSURLConnection
I'm getting a 502 Bad Gateway
error. With this response:
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GETÂ /couch/DATABASE_NAME/_changes.Reason: DNS lookup failure for: MY_SERVER_ADDRESS
Apache/2.2.22 (Ubuntu) Server at MY_SERVER_ADDRESS Port 80
I've gone so far as to copy and paste the exact URL and header fields from the NSURLRequest
into a curl request but I can't replicate the error in the terminal. I've also tried changing timeout values in the configuration file but it makes no difference.
N.B. This occurs on both an iOS device over the local network, and in the iOS simulator running on the same machine as the server (the server is a Virtual Machine running inside Virtual Box).