nginx as front end cache for WMS

tt5430 nginx-forum at nginx.us
Wed Mar 5 00:34:02 UTC 2014


Hi Anton,

I followed your suggestion and modified my conf files.  I also added some
new 
stuff but still could not get it to work.  I did not see any message written
to the access log and did not see anything written to the cache.  I included
my new conf files and a request/response block that I captured using FireFox
Live Http Headers addon.  I hope someone can catch my mistake and show me
what was wrong.  

[/etc/nginx/nginx.conf]
user vriuser;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        log_format geoserver-cache '$remote_addr - $upstream_cache_status
[$time_local]  '
            '"$request" $status $body_bytes_sent '
            '"$http_referer" "$http_user_agent"';
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

[/etc/nginx/sites-enabled/proxy.conf]
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header X-Cache $upstream_cache_status;

proxy_connect_timeout 60;
proxy_read_timeout 90;
proxy_send_timeout 60;

proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 100 8k;

[/etc/nginx/sites-enabled/geoserver.conf]
upstream backend {
  server localhost;
}

proxy_cache_path          /var/geoserver/cache  levels=1:2
keys_zone=geoserver-cache:10m inactive=7d max_size=5000m;
proxy_temp_path           /var/geoserver/cache/tmp;

server {
        listen       80;
        #server_name  localhost;
        #root         /home/geoserver/webapps/geoserver;
        root         /opt/tomcat/webapps/geoserver;

        proxy_redirect off;
        proxy_buffering           on;
        proxy_cache_valid         any 7d;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        access_log /var/log/nginx/geoserver/access.log geoserver-cache;
        error_log /var/log/nginx/geoserver/error.log;

        proxy_cache geoserver-cache;
        proxy_cache_valid 200 2h;
        proxy_cache_valid 302 2h;
        proxy_cache_valid 301 4h;
        proxy_cache_valid any 1m;
        resolver 127.0.0.1;

        location / {
            proxy_pass http://backend;
            proxy_cache_key $scheme://backend:8080/$request_uri;
            proxy_cache_valid       200;
        }
}

Request/Response headers:

http://localhost:8080/geoserver/osm/wms?LAYERS=Florida&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A3857&BBOX=-9046077.9720712,3223712.9634365,-9032807.336146,3240204.627499&WIDTH=412&HEIGHT=512

GET
/geoserver/osm/wms?LAYERS=Florida&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A3857&BBOX=-9046077.9720712,3223712.9634365,-9032807.336146,3240204.627499&WIDTH=412&HEIGHT=512
HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:23.0) Gecko/20100101
Firefox/23.0
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer:
http://localhost:8080/geoserver/osm/wms?service=WMS&version=1.1.0&request=GetMap&layers=Florida&styles=&bbox=-9735065.0,2733130.75,-8885187.0,3788597.25&width=412&height=512&srs=EPSG:3857&format=application/openlayers
Cookie: JSESSIONID=BDE023A90406794200BCF412045BC96C;
JSESSIONID=maqv107kg0me
Connection: keep-alive

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Disposition: inline; filename=Florida.png
Content-Type: image/png
Transfer-Encoding: chunked
Date: Wed, 05 Mar 2014 00:15:35 GMT

Regards,
Tam

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,248053,248117#msg-248117



More information about the nginx mailing list