日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
開發(fā)環(huán)境下如何進(jìn)行安全加固呢

由于公司機(jī)房和辦公環(huán)境是在一起的,默認(rèn)情況下公司出口IP是禁止80/443訪問(wèn)【運(yùn)營(yíng)商側(cè)有限制】。目前采用的是阿里云進(jìn)行中轉(zhuǎn),即將開發(fā)環(huán)境的域名解析到阿里云,然后通過(guò)Nginx反向代理到公司出口非80端口。開發(fā)環(huán)境部分接口涉及到第三方回調(diào)和校驗(yàn),所以完全禁止開發(fā)環(huán)境對(duì)外網(wǎng)訪問(wèn)不現(xiàn)實(shí)。

目前合理的需求如下:

  1. 公司網(wǎng)絡(luò)地址段可以訪問(wèn)開發(fā)環(huán)境不受限制
  2. 允許部分第三方IP地址段加入白名單
  3. 若第三方IP不固定,需支持第三方回調(diào)的URL加入白名單
  4. 不在上述條件內(nèi)全部禁止外網(wǎng)訪問(wèn)。

面對(duì)上述簡(jiǎn)單的需求場(chǎng)景,我們?nèi)绾螌?shí)現(xiàn)呢?

方案一:采用防火墻白名單策略進(jìn)行實(shí)現(xiàn),目前看只能實(shí)現(xiàn) 1 和 2 的條件

方案二:采用Nginx的allow、deny等策略,目前看也只能實(shí)現(xiàn) 1 和 2 的條件

方案三:采用Nginx+Lua 通過(guò)access_by_lua_file策略,目前看能實(shí)現(xiàn)上述所有條件而且實(shí)現(xiàn)起來(lái)比較簡(jiǎn)單,改造成本較小。

  1. 在Nginx的server層配置:access_by_lua_file 'scripts/filter_white.lua'
  2. filter_white.lua 腳本配置信息: 
 
 
  1. root@develop:/usr/local/nginx/scripts# cat filter_white.lua  
  2. -- 默認(rèn)配置 
  3. local redis = require 'resty.redis' 
  4. local allow = false 
  5.  
  6. -- 連接Redis 
  7. local red = redis:new() 
  8. local ok, err = red:connect('172.17.173.183', 26379) 
  9. if not ok then 
  10.     ngx.log(ngx.ERR, 'connect to redis failed: ' .. err) 
  11. end 
  12.  
  13. local res, err = red:auth('Huajianghu@123') 
  14. if not res then 
  15.     ngx.log(ngx.ERR, 'failed to authenticate: ' .. err) 
  16. end 
  17.  
  18. -- 過(guò)濾精確IP 
  19. --if red:sismember('white:dev:ip', ngx.var.remote_addr) == 1 then 
  20. --    allow = true 
  21. --end 
  22.  
  23. -- 過(guò)濾IP地址段 
  24. local iputils = require("resty.iputils") 
  25. iputils.enable_lrucache() 
  26. local white_ips =red:smembers('white:dev:ip') 
  27. local whitelist = iputils.parse_cidrs(white_ips) 
  28. if iputils.ip_in_cidrs(ngx.var.remote_addr, whitelist) then 
  29.     allow = true 
  30. end  
  31.  
  32. -- 過(guò)濾URL 
  33. if not allow then 
  34.         local url = ngx.var.http_host .. ngx.var.uri 
  35.         local white_urls = red:smembers('white:dev:url') 
  36.         for index, white_url in ipairs(white_urls) do 
  37.                 if url:match(white_url) then 
  38.                         allow = true 
  39.                         break 
  40.                 end 
  41.         end 
  42. end 
  43.  
  44. -- 默認(rèn)策略 
  45. if not allow then 
  46.     ngx.log(ngx.ERR, "not allow: " .. ngx.var.http_host .. ngx.var.uri) 
  47.     ngx.status = ngx.HTTP_FORBIDDEN 
  48.     ngx.say('請(qǐng)申請(qǐng)白名單') 
  49.     ngx.exit(200) 
  50. end 

3.此腳本僅供參考使用,特殊場(chǎng)景需要進(jìn)行修改lua腳本。


新聞標(biāo)題:開發(fā)環(huán)境下如何進(jìn)行安全加固呢
瀏覽路徑:http://www.5511xx.com/article/cdeepjo.html