定义js.map文件只允许内网或者指定IP访问

案例配置:


server {
        listen 443;
        server_name *****.com;
        ssl on;
        ssl_certificate   sslkey/****/****.com.pem;
        ssl_certificate_key  sslkey/****/****.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
        ssl_prefer_server_ciphers on;
        include ***.conf;
        location  /***/ {
                index index.html index.htm;
                alias /*****.com/***/;
                try_files $uri $uri/ /****/index.html;
                #判断是否是静态文件,如果是静态文件则不缓存
                 if ($request_filename ~ .*\.(htm|html)$)
                {
                add_header Cache-Control "no-cache, no-store";
                }
            #匹配访问js.map文件的访问权限
            location ~ .*\.(js.map)?$ {
                    set_real_ip_from {your IP}; #定义可以访问的源IP
                    real_ip_header    X-Forwarded-For; #表示从哪个header属性中获取真实IP
                    real_ip_recursive on; #递归检索真实IP,若从 X-Forwarded-For 中获取,则需递归检索;若像从X-Real-IP中获取,则无需递归。
                    proxy_set_header X-Forwarded-For $remote_addr; #$remote_addr 是客户端真实IP
                    #判断访问源IP如果不是{your IP}则返回403
                    if ($remote_addr != your IP) {
                        return 403;
                        }
                    #定义proxy1日志输出路径
                    access_log /***/***.log proxy1;
                    }
        }
        location = /favicon.ico {
            log_not_found off;
       }

        access_log  /data/****/*****.com.log  access;
}
server {
        listen 80;
        server_name *******.com;
        return 307 https://$host$request_uri;
}

   转载规则


《定义js.map文件只允许内网或者指定IP访问》 helen 采用 知识共享署名 4.0 国际许可协议 进行许可。
  目录