Nginx cache agent

The map tiles on the ArcGIS official website are too slow. Think of the available NIGIX proxy.

Nginx is http proxy software under Linux, and it is also available under Windows.

The following is the configuration method, pay attention to the red part.

1. You need to create a new folder in the directory D:\nginxCache specified by the local proxy_cache_path. Requests to access http will be cached here.

2, just open Nigix. Check whether there are successive files generated in this cache directory.

share picture

3. The meaning of this configuration is that the request to access http://localhost:8090 is redirected to https://services.arcgisonline.com. Cache requests for 720 hours at the same time.

For each request, add the Head information, KeDu-Nginx-Cache.

share picture

Share pictures

< /p>

MISS is the first visit, obtained from the server arcgisonline

HIT stands for hit cache, obtained from the local cache nignxCache

..\nginx-1.14.2\conf\nginx.conf is configured as follows:

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

< p>
events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

proxy_cache_path d:/nginxcache levels=1:2 keys_zone=cacheZone:20m max_size=50g inactive=720h;

#log_format main’$remote_addr-$remote_user [$time_local] “$request”‘
#’$status $body_bytes_sent “$http_referer”‘
#'”$http_user_ag ent” “$http_x_forwarded_for”‘;

access_log logs/access.log;

server_names_hash_bucket_size 100;

sendfile on;
#tcp_nopush on;

p>

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 8089;
server_name localhost;

location / {
< span style="color: #ff0000;">add_header KeDu-Nginx-Cache “$upstream_cache_status form $server_addr”;
add_header KeDu-Nginx-Cache “ArcGISOnline”;

proxy_passhttps://services.arcgisonline.com span>;

proxy_cache cacheZone;
proxy_cache_key “$ scheme$host$request_uri”;
proxy_cache_valid 720h;

proxy_ignore_headers Set-Cookie Cache-Contro l;
proxy_hide_header Cache-Control;
proxy_hide_header Set-Cookie; }} }

Leave a Comment

Your email address will not be published.