I hope you will forgive my asking for help on what I assume is a fairly
obvious error of some sort -- but it's one I'm afraid I can't figure
out.<br><br>Basically, we have a cherrypy back end server that will resolve layer names to IP address, handling requests of the form:<br>
<br> /resolve?layer=terrain<br><br>or<br><br> /resolve?layer=es_layer_23<br><br>The back end server sets a memcache key/value pair so that the next time around, nginx can avoid the "@cache_miss" proxy pass the next time around.<br>
<br>
For the most part, all works well -- if I request the name of a key in the <span class="nfakPe">memcached</span>, ("terrain", for example) -- it gets returned. Likewise, if I request a key NOT in <span class="nfakPe">memcached</span>, the request gets sent to my server.<br>
<br>However, any layers with a name starting with "es_" will always go
to the same host -- so no need to clutter <span class="nfakPe">memcached</span> with lots of keys -- I'd like to just convert the key so that it is identical for all such requests...<br>
<br>When I attempt to do so using the code fragment below, however, I
get what I believe is unusual behavior -- requests for anything
starting with "es_" return nothing -- no HTTP headers, no data -- the socket just closes.<br>
<br>Any thoughts on why?<br><br>Thanks,<br><br>--Tom<br><br><br><br>The nginx configuration file:<br><br>server {<br> listen 80;<br> server_name <a href="http://api.earthscape.com">api.earthscape.com</a>;<br>
<br> access_log /data/log/nginx/access.log;<br> error_log /data/log/nginx/error.log;<br><br> location ^~ /static/ {<br> root /data/www;<br> }<br><br> location /resolve {<br>
default_type text/html;<br><br> set $memcached_key "api:/resolve?$args";<br> if ($args ~ "layer=es_") {<br> set $memcached_key "api:/resolve?layer=es_";<br>
}<br> memcached_pass localhost:11211;<br> error_page 404 = /;<br> }<br><br> # proxy everything else to cherrypy on same computer, port 9000<br> #<br> location / {<br>
proxy_pass <a href="http://192.168.1.17:9000">http://192.168.1.17:9000</a>;<br> }<br>}<br><br><br>The CherryPy function:<br><br> def resolve(self,layer):<br><br> if layer == 'iphone':<br>
host = "<a href="http://208.42.229.173">208.42.229.173</a>"<br> cherrypy.thread_data.mc.set("api:/resolve?layer=iphone", host)<br> return host # iphone imagery - go to cacheing load balancer first<br>
elif layer == 'terrain':<br> host = "<a href="http://208.42.248.164">208.42.248.164</a>"<br> cherrypy.thread_data.mc.set("api:/resolve?layer=terrain", host)<br> return host # terrain is on a random nginx imagery server<br>
elif layer.startswith('es_'):<br> host = "<a href="http://208.42.229.170">208.42.229.170</a>"<br> cherrypy.thread_data.mc.set("api:/resolve?layer=es_", host)<br> return host # All earthscape layers will be on <a href="http://info.earthscape.com">info.earthscape.com</a><br>
else:<br> return 'not valid'<br><br> resolve.exposed = True<br><br><br>