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

ʹÓÃNginx Proxy ManagerʵÏÖAPIÍø¹ØµÄÈÏÖ¤ÓëÊÚȨ

ʹÓÃNginx Proxy ManagerʵÏÖAPIÍø¹ØµÄÈÏÖ¤ÓëÊÚȨ

×÷ΪÏÖ´ú»¥ÁªÍøÓ¦Óÿª·¢ÖеÄÖ÷Òª×é³É²¿·Ö£¬APIÍø¹ØÔÚÌṩ½Ó¿ÚŲÓõÄͬʱ£¬Ò²ÐèÒª°ü¹Ü½Ó¿ÚµÄÇå¾²ÐÔ¡£ÆäÖУ¬ÈÏÖ¤ÓëÊÚȨÊÇAPIÍø¹Ø²»¿É»òȱµÄ¹¦Ð§£¬ÓÃÓÚÑéÖ¤ÇëÇóÕßµÄÉí·Ý²¢ÊÚÓè»á¼ûȨÏÞ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNginx Proxy ManagerʵÏÖAPIÍø¹ØµÄÈÏÖ¤ÓëÊÚȨ£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£

Ò»¡¢Ê²Ã´ÊÇNginx Proxy Manager

Nginx Proxy ManagerÊÇ»ùÓÚNginxµÄ·´ÏòÊðÀíºÍ¸ºÔØƽºâµÄÖÎÀí¹¤¾ß¡£ËüÌṩÁËÒ»¸ö¿ÉÊÓ»¯µÄÖÎÀí½çÃ棬Àû±ãÓû§ÉèÖúÍÖÎÀíNginxµÄÊðÀí¹æÔò¡£Nginx Proxy Manager¿ÉÒÔͨ¹ýÉèÖùæÔò¶ÔÇëÇó¾ÙÐÐת·¢£¬²¢Ö§³ÖÌí¼Ó×Ô½ç˵ÖÐÑë¼þÀ©Õ¹NginxµÄ¹¦Ð§¡£

¶þ¡¢ÈÏÖ¤ÓëÊÚȨ

ÔÚAPIÍø¹ØÖУ¬ÈÏÖ¤ÓëÊÚȨÊÇÒªº¦µÄÇå¾²²½·¥¡£ÈÏÖ¤ÓÃÓÚÑéÖ¤ÇëÇóÕßµÄÉí·Ý£¬Í¨³£½ÓÄÉAPIÃÜÔ¿¡¢Óû§ÃûÃÜÂëµÈ·½·¨¡£ÊÚȨÔòÊÇÔÚÈÏ֤ͨʺ󣬶ÔÇëÇóÕßµÄȨÏÞ¾ÙÐÐÅжÏ£¬¾öÒéÊÇ·ñÔÊÐí»á¼ûij¸ö½Ó¿Ú¡£

Èý¡¢Ê¹ÓÃNginx Proxy ManagerʵÏÖÈÏÖ¤ÓëÊÚȨ

×°ÖÃNginx Proxy Manager

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚЧÀÍÆ÷ÉÏ×°ÖÃNginx Proxy Manager¡ £¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°Öãº

$ sudo apt-get install nginx
$ sudo apt-get install npm
$ sudo npm install -g npx
$ sudo npx create-npx npx

µÇ¼ºó¸´ÖÆ

ÉèÖÃÈÏÖ¤

ÔÚNginx Proxy ManagerµÄÖÎÀí½çÃæÉÏ£¬ÕÒµ½¶ÔÓ¦µÄÊðÀí¹æÔòÉèÖÃÏÔÚÖÐÑë¼þÉèÖÃÖÐÌí¼ÓÈÏÖ¤ÖÐÑë¼þ¡£ÈÏÖ¤ÖÐÑë¼þ¿ÉÒÔƾ֤ÇëÇóÕßÌṩµÄÉí·ÝÐÅÏ¢¾ÙÐÐÑéÖ¤¡£ÒÔÏÂÊÇÒ»¸öʹÓÃAPIÃÜÔ¿¾ÙÐÐÈÏÖ¤µÄʾÀý´úÂ룺

location /api {
    auth_basic "API Authentication";
    auth_basic_user_file /etc/nginx/.htpasswd;
    proxy_pass http://backend;
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊö´úÂëÖУ¬auth_basicÓÃÓÚÉèÖÃÈÏÖ¤ÌáÐÑÐÅÏ¢£¬auth_basic_user_fileÓÃÓÚÖ¸¶¨ÉúÑÄAPIÃÜÔ¿µÄÎļþ¡£Æ¾Ö¤ÏÖʵÐèÒª£¬¿ÉÒÔ×Ô½ç˵ÈÏÖ¤·½·¨£¬²¢Ìí¼ÓÏìÓ¦µÄÑéÖ¤Âß¼­¡£

ÉèÖÃÊÚȨ

ÊÚȨµÄʵÏÖ·½·¨ÓëÈÏÖ¤ÀàËÆ£¬Ò²ÊÇÔÚÊðÀí¹æÔòÉèÖÃÏîµÄÖÐÑë¼þÉèÖÃÖÐÌí¼ÓÊÚȨÖÐÑë¼þ¡£ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄÊÚȨʾÀý´úÂ룺

location /api {
    auth_basic "API Authentication";
    auth_basic_user_file /etc/nginx/.htpasswd;
    proxy_pass http://backend;
    if ($http_token != "123456") {
        return 403;
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊö´úÂëÖУ¬Í¨¹ýÅжÏÇëÇóÖÐÊÇ·ñ°üÀ¨×¼È·µÄ»á¼ûÁîÅÆ£¨token£©£¬¾öÒéÊÇ·ñ·µ»Ø403¹ýʧ£¨¼´ÎÞȨÏÞ£©¡£Æ¾Ö¤ÏÖʵÐèÒª£¬¿ÉÒÔ×Ô½ç˵ÊÚȨ·½·¨£¬²¢Ìí¼ÓÏìÓ¦µÄÊÚȨÂß¼­¡£

ËÄ¡¢×ܽá

±¾ÎÄÏÈÈÝÁËʹÓÃNginx Proxy ManagerʵÏÖAPIÍø¹ØµÄÈÏÖ¤ÓëÊÚȨµÄÒªÁ죬²¢ÌṩÁËÏêϸµÄ´úÂëʾÀý¡£Í¨¹ýÉèÖÃÈÏÖ¤ºÍÊÚȨÖÐÑë¼þ£¬ÎÒÃÇ¿ÉÒÔÎÞаµØƾ֤ӪҵÐèÇ󣬶ÔAPIÇëÇó¾ÙÐÐÉí·ÝÑéÖ¤ºÍȨÏÞ¿ØÖÆ£¬°ü¹Ü½Ó¿ÚŲÓõÄÇå¾²ÐÔ¡£Ï£Íû±¾ÎĶÔÄúÃ÷È·ºÍʵ¼ùAPIÍø¹ØµÄÈÏÖ¤ÓëÊÚȨÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇʹÓÃNginx Proxy ManagerʵÏÖAPIÍø¹ØµÄÈÏÖ¤ÓëÊÚȨµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ