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

nginx°×Ãûµ¥ÔõôÉèÖÃ

nginx °×Ãûµ¥ÏÞÖÆ»á¼ûÌض¨ÄÚÈÝ £¬½öÔÊÐíÀ´×ÔÊÚȨȪԴµÄÇëÇó¡£ÉèÖð취ÈçÏ£ºÈ·¶¨ÔÊÐíµÄ ip µØµã»òÓòÃû¡£½¨Éè nginx ЧÀÍÆ÷¿éÀ´´¦ÀíÇëÇó¡£Ìí¼Ó allow Ö¸Áî £¬ÔÊÐíÖ¸¶¨ÈªÔ´»á¼û¡£Ìí¼Ó deny Ö¸Á¿ÉÑ¡£© £¬¾Ü¾ø³ý°×Ãûµ¥ÍâµÄËùÓлá¼û¡£ÉúÑÄÉèÖò¢ÖØмÓÔØ nginx¡£

ÔõÑùÉèÖà nginx °×Ãûµ¥

ÔÚ nginx ÖÐ £¬°×Ãûµ¥ÊÇÒ»ÖÖ»á¼û¿ØÖÆ»úÖÆ £¬ÓÃÓÚÏÞÖƶÔÍøÕ¾»òÓ¦ÓóÌÐòÌض¨²¿·ÖµÄ»á¼û £¬½öÔÊÐíÀ´×ÔÊÚȨȪԴµÄÇëÇó¡£ÒÔÏ°취˵Ã÷ÎúÔõÑùÉèÖà nginx °×Ãûµ¥£º

1. È·¶¨ÔÊÐíµÄ IP µØµã»òÓòÃû

Ê×ÏÈ £¬È·¶¨ÒªÔÊÐí»á¼ûÊܱ£»¤ÄÚÈÝµÄ IP µØµã»òÓòÃû¡£ÕâЩ¿ÉÄÜÊÇÄã×Ô¼ºµÄ IP µØµã¡¢ÊÜÐÅÍеÄÏàÖúͬ°é»ò¿Í»§µÄ IP µØµã¡£

2. ½¨Éè nginx ÉèÖÿé

ÔÚ nginx ÉèÖÃÎļþÖÐ £¬½¨ÉèÒ»¸öеÄЧÀÍÆ÷¿éÀ´´¦Àí½«Ó¦Óð×Ãûµ¥µÄÇëÇó¡£

3. Ìí¼Ó allow Ö¸Áî

ÔÚЧÀÍÆ÷¿éÖÐ £¬Ìí¼ÓÒÔÏ allow Ö¸Áî £¬ÒÔÔÊÐíÀ´×ÔÖ¸¶¨ IP µØµã»òÓòÃûµÄ»á¼û£º

allow 192.168.0.1;
allow example.com;

µÇ¼ºó¸´ÖÆ

4. Ìí¼Ó deny Ö¸Á¿ÉÑ¡£©

ÈôÊÇÄãÏ£Íû¾Ü¾ø³ý°×Ãûµ¥ÒÔÍâµÄËùÓлá¼û £¬Ôò¿ÉÒÔÌí¼Ó deny Ö¸Á

deny all;

µÇ¼ºó¸´ÖÆ

5. ÉúÑÄÉèÖò¢ÖØмÓÔØ nginx

ÉúÑÄ nginx ÉèÖÃÎļþ²¢½«¸ü¸ÄÓ¦ÓÃÓÚЧÀÍÆ÷£º

sudo systemctl reload nginx

µÇ¼ºó¸´ÖÆ

ʾÀýÉèÖÃ

ÒÔÏÂÊÇ nginx °×Ãûµ¥ÉèÖÃʾÀý£º

server {
    listen 80;

    location /protected/ {
        allow 192.168.0.1;
        allow example.com;
        deny all;
    }
}

µÇ¼ºó¸´ÖÆ

´ËÉèÖý«ÔÊÐíÀ´×Ô 192.168.0.1 IP µØµãºÍ example.com ÓòÃûµÄÇëÇó»á¼û /protected/ Ŀ¼ £¬¶ø¾Ü¾øËùÓÐÆäËûÇëÇó¡£

ÒÔÉϾÍÊÇnginx°×Ãûµ¥ÔõôÉèÖõÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ