Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to proxy mapquest OSM tiles so I can serve them to my users via SSL. This is what my nginx config looks like:

upstream maptile_server {

server {

    # ...


    location /tiles {
            proxy_pass http://maptile_server;

So if a map tile exists at, I want to access it at

Currently I'm getting an "Invalid URL" error.


I also considered doing something like this:

location ~ /maptiles/(?<subdomain>.+)/(?<z>.+)/(?<x>.+)/(?<y>.+) {
    return http://$$z/$x/$y;

But this redirects me to the final url rather than proxying the request. Is there any way to hide the final URL from the client?

share|improve this question

Perhaps you are forgetting proxy_set_header Host "";?

Notice that all your upstream servers will have to be capable of accepting such Host header as valid and appropriate.

If you don't manually define a Host header, then perhaps no host header will be provided to the upstream.

The documentation is not exactly clear of what Host is set to by default if the upstream module is used; but your situation may sound like some functionality might currently be missing!

share|improve this answer
This causes it to work! but since I'm using multiple upstream servers, I don't see a way to adjust the Host header based on which server nginx chooses. – kbanman Mar 7 '13 at 5:24
Yes, and this is already briefly addressed in my answer. In most situations, if you have multiple upstreams, then it is implied that you control all of them, and would have little trouble ensuring that they reply uniformly through a given Host. Else, if you have no control over them, then it is most likely that you don't really need to specify more than one upstream in the first place. :-) – cnst Mar 7 '13 at 6:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.