尊龙凯时人生就是博

ʹÓÃ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
sitemap¡¢ÍøÕ¾µØͼ