×ðÁú¿­Ê±¹ÙÍøµÇ¼

NginxÇå¾²·À»ðǽÉèÖà £¬±£»¤ÍøÕ¾²»ÊܶñÒâ¹¥»÷

nginxÇå¾²·À»ðǽÉèÖà £¬±£»¤ÍøÕ¾²»ÊܶñÒâ¹¥»÷

СÐò£º

ÔÚµ±½ñ»¥ÁªÍøʱ´ú £¬ÍøÕ¾ÃæÁÙ×ÅÖÖÖÖÇå¾²Íþв £¬Èç¶ñÒâ¹¥»÷¡¢ÈëÇֵȡ£ÎªÁ˱£»¤ÍøÕ¾µÄÊý¾ÝºÍÓû§Òþ˽ £¬ÎÒÃÇÐèÒª½ÓÄÉһϵÁв½·¥À´ÔöÇ¿ÍøÕ¾µÄÇå¾²ÐÔ¡£NginxÊÇÒ»¸ö¸ßÐÔÄܵÄWebЧÀÍÆ÷ £¬ÔÚÇå¾²·½ÃæÒ²ÌṩÁ˸»ºñµÄ¹¦Ð§ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýNginxµÄ·À»ðǽÉèÖÃÀ´±£»¤ÍøÕ¾ÃâÊܶñÒâ¹¥»÷¡£

Ò»¡¢NginxÇå¾²·À»ðǽÉèÖÃ

×°ÖÃNginx

Ê×ÏÈ £¬ÎÒÃÇÐèҪװÖÃNginxЧÀÍÆ÷¡ £¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´×°ÖÃNginx£º

$ sudo apt update
$ sudo apt install nginx

µÇ¼ºó¸´ÖÆ

ÉèÖÃNginx·À»ðǽ

NginxµÄ·À»ðǽ¹¦Ð§Í¨¹ýÉèÖÃÎļþnginx.confÀ´ÊµÏÖ¡£·­¿ªnginx.confÎļþ £¬ÕÒµ½http²¿·ÖµÄÉèÖöΠ£¬Ìí¼ÓÒÔÏÂÄÚÈÝ£º

http {
    # ÔÊÐíµÄIPÁбí
    deny 192.168.0.1;
    allow 192.168.0.0/24;
    
    # ±ÜÃâĿ¼±éÀú¹¥»÷
    location ~ /. {
        deny all;
    }
    
    # ±ÜÃâSQL×¢Èë¹¥»÷
    location ~ inj/ {
        deny all;
    }
    
    # ÏÞÖÆHTTPÇëÇóÒªÁì
    if ($request_method !~ ^(GET|HEAD|POST)$) {
        return 444;
    }
    
    # եȡĿ¼Ë÷ÒýµÄ»á¼û
    location ~ ^/(.|php) {
        deny all;
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃʾÀýÖÐ £¬denyÓÃÓھܾøÌض¨µÄIPµØµã £¬allowÓÃÓÚÔÊÐíÌض¨µÄIPµØµã¶Î¡£Í¨¹ýÕâÑùµÄÉèÖà £¬ÎÒÃÇ¿ÉÒÔÏÞÖÆÖ»ÓÐÌض¨µÄIPµØµãÄܹ»»á¼ûÎÒÃǵÄÍøÕ¾¡£

location ~ /. { deny all; } Õâ¶ÎÉèÖÃÓÃÓÚ±ÜÃâĿ¼±éÀú¹¥»÷ £¬µ±»á¼ûURL°üÀ¨”../”ʱ £¬·µ»Ø403 Forbidden¡£

location ~ inj/ { deny all; } Õâ¶ÎÉèÖÃÓÃÓÚ±ÜÃâSQL×¢Èë¹¥»÷ £¬µ±URL°üÀ¨”inj/”ʱ £¬·µ»Ø403 Forbidden¡£

if ($request_method !~ ^(GET|HEAD|POST)$) { return 444; } Õâ¶ÎÉèÖÃÓÃÓÚÏÞÖÆHTTPÇëÇóÒªÁì £¬Ö»ÔÊÐíGET¡¢HEAD¡¢POSTÈýÖÖÒªÁì £¬ÆäËûÒªÁì·µ»Ø444ÌåÏÖÎÞÏìÓ¦¡£

location ~ ^/(.|php) { deny all; } Õâ¶ÎÉèÖÃÓÃÓÚեȡ¶ÔĿ¼Ë÷ÒýµÄ»á¼û £¬µ±URLÒÔ”/.”»ò”.php”×îºóʱ £¬·µ»Ø403 Forbidden¡£

ÖØÆôNginxЧÀÍÆ÷

Íê³ÉÒÔÉÏÉèÖúó £¬ÎÒÃÇÐèÒªÖØÆôNginxЧÀÍÆ÷ʹÉèÖÃÉúЧ£º

$ sudo systemctl restart nginx

µÇ¼ºó¸´ÖÆ

¶þ¡¢×ܽá

ͨ¹ýNginxµÄ·À»ðǽÉèÖà £¬ÎÒÃÇ¿ÉÒÔÓÐÓõر£»¤ÎÒÃǵÄÍøÕ¾²»ÊܶñÒâ¹¥»÷¡£ÕâЩÉèÖÃÖ»ÊÇÈëÃż¶±ðµÄ·À»¤²½·¥ £¬¹ØÓÚ¸üÖØ´óµÄ¹¥»÷ £¬ÎÒÃÇÐèÒª½øÒ»²½ÔöÇ¿ÍøÕ¾µÄÇå¾²ÐÔ £¬ÈçʹÓÃWebÓ¦ÓóÌÐò·À»ðǽ£¨WAF£©¡¢HTTPSµÈ¡£ÔÚ½¨ÉèÇå¾²ÍøÕ¾µÄÀú³ÌÖÐ £¬ÎÒÃÇÐèÒªÇ×½ü¹Ø×¢×îеÄÇå¾²ÍþвºÍÎó²î £¬²¢ÊµÊ±¸üкÍÍêÉÆ·À»¤²½·¥ £¬Ìá¸ßÍøÕ¾µÄÇå¾²ÐÔ¡£

ÒÔÉÏÊǹØÓÚNginxÇå¾²·À»ðǽÉèÖõÄÏÈÈÝ £¬Ï£Íû¶Ô¸÷ÈËÓÐËù×ÊÖú¡£Í¨¹ýºÏÀíµÄÉèÖúͷÀ»¤²½·¥ £¬ÎÒÃÇ¿ÉÒÔ°ü¹ÜÍøÕ¾µÄÇå¾² £¬Ìṩ¸üºÃµÄÓû§ÌåÑé¡£

ÒÔÉϾÍÊÇNginxÇå¾²·À»ðǽÉèÖà £¬±£»¤ÍøÕ¾²»ÊܶñÒâ¹¥»÷µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ