Server sent unexpected return value (502 Bad Gateway) in response to COPY

This was an annoying issue. I initially blamed it on an Apache update and wasted a lot of time going in that direction. When I finally gave up and used Google, I got somewhere.

Thankfully, I wasn’t the only person to run into this and there are at least three different solutions to the problem. Take your pick.

It was explained rather succinctly here:

because nginx pass to backend https:// url in Destination header.
but http:// and https:// urls can not be mixed in COPY request.

In short, the front end speaks https to the client, but it speaks http (non-ssl) to the back end. The header is not changed to reflect this and the COPY command fails.

  1. Rewrite the Destination header via nginx’s rewrite feature:

    set $fixed_destination $http_destination;
    if ( $http_destination ~* ^https(.*)$ )
    set $fixed_destination http$1;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Destination $fixed_destination;
    proxy_pass http://subversion_hosts;

  2. Have Apache also use SSL (I was using this approach until just recently)
  3. Use mod_headers with Apache.


I’ve spent the last several weeks testing a new server configuration and finally got some time to implement it. I figured a few hours and I would be done, but I kept running into minor issues that I didn’t uncover or didn’t fully test within my dev environment.

So yeah, it’s now working. nginx isn’t as big a beast as I thought it would be, thanks to a lot of good documentation.

I started with Nginx HTTP Server ( and used a variety of web resources to round out the rest. We’ll see what the world throws against it tomorrow and reconfigure accordingly.

Redmine rocks

I got my first taste of setting up a Ruby on Rails webapp last month when I stumbled across Redmine while researching project management/issue tracking systems. I wanted a setup that supported:

  • Multiple projects support
  • Fine grained access control
  • Customizable issue tracking
  • Feeds & email notifications
  • LDAP authentication support
  • Per project wiki
  • News, documents & files management
  • Subversion integration
In addition to those things, it also has:
  • Per project wiki
  • Per project forums
  • Time tracking
  • Custom fields for issues, time-entries, projects and users
  • Issue creation via email
  • User self-registration support
  • Multilanguage support
  • Multiple databases support

and it’s an active and widely used project. I was worried to start with that the bad performance I was getting was a sign that it would never hold up on my new VPS hosted server, but after some Apache config tweaking it’s running pretty solid and is quite snappy.

That said I’m just one user, but my needs are small so I ought to be alright. With a beefy server running it, that app will fly.