尊龙凯时人生就是搏

ÉîÈëÃ÷È·NginxµÄÏÞÖÆÇëÇóËÙÂʺͱÜÃâ¶ñÒâÇëÇóµÄÇå¾²·À»¤Õ½ÂÔ

ÉîÈëÃ÷È·nginxµÄÏÞÖÆÇëÇóËÙÂʺͱÜÃâ¶ñÒâÇëÇóµÄÇå¾²·À»¤Õ½ÂÔ

NginxÊÇÒ»¿î¸ßÐÔÄܵĿªÔ´WebЧÀÍÆ÷ £¬Ëü²»µ«½ö¿ÉÒÔÓÃÀ´°²Åž²Ì¬ÍøÕ¾¡¢·´ÏòÊðÀíºÍ¸ºÔØƽºâ £¬»¹¿ÉÒÔͨ¹ýһϵÁеÄÇå¾²·À»¤Õ½ÂÔÀ´±  £»¤ÎÒÃǵÄЧÀÍÆ÷ÃâÊܶñÒâÇëÇóµÄ¹¥»÷¡£±¾ÆªÎÄÕ½«ÖصãÏÈÈÝNginxµÄÏÞÖÆÇëÇóËÙÂʺͱÜÃâ¶ñÒâÇëÇóµÄÇå¾²·À»¤Õ½ÂÔ £¬²¢ÌṩÏà¹ØµÄ´úÂëʾÀý¡£

ÏÞÖÆÇëÇóËÙÂÊ

¶ñÒâÇëÇóÍùÍùÒÔ´ó×Ú¸ßƵµÄ·½·¨Ìᳫ £¬¸øЧÀÍÆ÷´øÀ´ÖØ´óµÄѹÁ¦ £¬ÎªÁË×èֹЧÀÍÆ÷¹ýÔØ £¬ÎÒÃÇ¿ÉÒÔʹÓÃNginxµÄÄ£¿éÀ´ÏÞÖÆÇëÇóµÄËÙÂÊ¡£

ÔÚNginxµÄÉèÖÃÎļþÖÐ £¬¿ÉÒÔͨ¹ýlimit_req_zoneÖ¸ÁîÀ´½¨ÉèÒ»¸öÇëÇóËÙÂÊÏÞÖƵĹ²ÏíÄÚ´æÇøÓò £¬ÀýÈ磺

http {
    limit_req_zone $binary_remote_addr zone=limit:10m rate=1r/s;
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖý¨ÉèÁËÒ»¸ö10MB¾ÞϸµÄÄÚ´æÇøÓò £¬ÏÞÖÆÿÃëÖÓ´Óͳһ¸ö¿Í»§¶ËIPµØµãÌᳫµÄÇëÇóÊý²»Áè¼Ý1¸ö¡£½ÓÏÂÀ´ £¬ÎÒÃÇ¿ÉÒÔÔÚÏêϸµÄÇëÇó´¦Àí¿éÖÐʹÓÃlimit_reqÖ¸ÁîÀ´Ó¦ÓÃÕâ¸öÏÞÖÆ £¬ÀýÈ磺

server {
    location /api/ {
        limit_req zone=limit burst=5;
        proxy_pass http://backend;
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÌåÏÖÔÚ/api/·¾¶ÏÂÏÞÖÆÇëÇóËÙÂÊ £¬²¢ÉèÖÃÁËÒ»¸öÍ»·¢ÏÞÖÆֵΪ5¡£ÕâÑùÒ»À´ £¬ÈôÊÇÓдó×ÚµÄÇëÇóÁè¼ÝÁËÏÞÖÆËÙÂÊ £¬Nginx½«·µ»Ø503¹ýʧ¸ø¿Í»§¶Ë £¬²¢ÑïÆúÕâЩÇëÇó¡£

±ÜÃâ¶ñÒâÇëÇó

³ýÁËÏÞÖÆÇëÇóËÙÂÊ £¬ÎÒÃÇ»¹¿ÉÒÔͨ¹ýÆäËûÕ½ÂÔÀ´±ÜÃâ¶ñÒâÇëÇó £¬ÀýÈ磺

IP°×Ãûµ¥/ºÚÃûµ¥£º¿ÉÒÔͨ¹ýallowºÍdenyÖ¸ÁîÀ´ÉèÖÃIPµÄ»á¼û¿ØÖÆ £¬Ö»ÔÊÐí°×Ãûµ¥ÖеÄIP»á¼û £¬»òÕß×èµ²ºÚÃûµ¥ÖеÄIP¡£ÀýÈ磺

location /admin/ {
    allow 192.168.1.0/24;
    deny all;
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÌåÏÖÖ»ÔÊÐíIPÔÚ192.168.1.0/24Íø¶ÎÄڵĻá¼û/admin/·¾¶¡£

URIºÚÃûµ¥£º¿ÉÒÔͨ¹ýifÖ¸ÁîºÍÕýÔò±í´ïʽÀ´×èµ²¶ñÒâÇëÇóµÄURI¡£ÀýÈ磺

location / {
    if ($uri ~* "/wp-admin" ) {
        return 403;
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÌåÏÖÈôÊÇÇëÇóµÄURIÖаüÀ¨/wp-admin £¬Ôò·µ»Ø403¹ýʧ¡£

Referer¼ì²é£º¿ÉÒÔͨ¹ý¼ì²éÇëÇóÍ·ÖеÄReferer×Ö¶ÎÀ´ÅжÏÇëÇóµÄȪԴÊÇ·ñÕýµ±¡£ÀýÈ磺

server {
    location / {
        if ($http_referer !~* "^https?://example.com") {
            return 403;
        }
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÌåÏÖÈôÊÇReferer×ֶβ»ÊÇÒÔhttp://example.com»òhttps://example.com¿ªÍ· £¬Ôò·µ»Ø403¹ýʧ¡£

×ÛÉÏËùÊö £¬NginxÌṩÁ˸»ºñµÄÏÞÖÆÇëÇóËÙÂʺͱÜÃâ¶ñÒâÇëÇóµÄÇå¾²·À»¤Õ½ÂÔ¡£Í¨¹ýºÏÀíÉèÖÃNginx £¬ÎÒÃÇ¿ÉÒÔ±  £»¤Ð§ÀÍÆ÷ÃâÊܶñÒâÇëÇóµÄ¹¥»÷ £¬Ìá¸ßЧÀÍÆ÷µÄÎȹÌÐÔºÍÇå¾²ÐÔ¡£

ÒÔÉϾÍÊǶÔÉîÈëÃ÷È·nginxµÄÏÞÖÆÇëÇóËÙÂʺͱÜÃâ¶ñÒâÇëÇóµÄÇå¾²·À»¤Õ½ÂÔµÄÏÈÈÝ £¬Ï£ÍûÄܶԶÁÕßÓÐËù×ÊÖú¡£

£¨×¢£ºÒÔÉÏÖ»ÊÇ´úÂëʾÀý £¬²¢·×Æ綨ÍêÕûÊÊÓÃÓÚÉú²úÇéÐÎ £¬Çëƾ֤ÏÖÕæÏàÐÎÍŽáNginxµÄ¹Ù·½Îĵµ¾ÙÐÐÉèÖᣣ©

ÒÔÉϾÍÊÇÉîÈëÃ÷È·NginxµÄÏÞÖÆÇëÇóËÙÂʺͱÜÃâ¶ñÒâÇëÇóµÄÇå¾²·À»¤Õ½ÂÔµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ