zoukankan      html  css  js  c++  java
  • Nginx 缓存代理

    访问ArcGIS官网的地图瓦片太慢。想到可用NIGIX代理。

    Nginx是Linux下http代理软件,Windows下也有。

    以下为配置方法,注意红色部分。

    1、需要在本地proxy_cache_path所指定的目录D: ginxCache新建文件夹。访问http的请求将缓存在此。

    2、打开Nigix即可。查看此缓存目录是否有陆续文件生成。

    3、此配置,意义是,对访问http://localhost:8090的请求,转向https://services.arcgisonline.com 。同时缓存请求720小时。

    对每个请求,添加的Head信息,KeDu-Nginx-Cache。

    MISS为首次访问,从服务器arcgisonline获取

    HIT代表命中缓存,从本机缓存nignxCache获取

    .. ginx-1.14.2conf ginx.conf配置如下:


    #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;


    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_agent" "$http_x_forwarded_for"';

    access_log logs/access.log;

    server_names_hash_bucket_size 100;

    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;

    #gzip on;

    server { 
    listen 8089;
    server_name localhost;

    location / {
    add_header KeDu-Nginx-Cache "$upstream_cache_status form $server_addr";
    add_header KeDu-Nginx-Cache "ArcGISOnline"; 

    proxy_pass https://services.arcgisonline.com;

    proxy_cache cacheZone;
    proxy_cache_key "$scheme$host$request_uri";
    proxy_cache_valid 720h;

    proxy_ignore_headers Set-Cookie Cache-Control;
    proxy_hide_header Cache-Control;
    proxy_hide_header Set-Cookie;


    }

  • 相关阅读:
    2019-07-26
    2019-07-25
    免费的论文查重网站
    图片转链接
    hexo GitHub创建博客是遇到的问题
    苹果手机安装小火箭
    旅游--南京
    查看电脑基本信息以及电脑性能分析
    Android 不能root
    x-mind ZEN 指定安装路径(其他默认安装c盘可参考)
  • 原文地址:https://www.cnblogs.com/wigis/p/11313984.html
Copyright © 2011-2022 走看看