¹¹½¨Çå¾²¿É¿¿µÄÍøÂçÓ¦ÓãºNginx Proxy ManagerµÄ¼Ü¹¹Éè¼Æ
¹¹½¨Çå¾²¿É¿¿µÄÍøÂçÓ¦ÓãºNginx Proxy ManagerµÄ¼Ü¹¹Éè¼Æ
ͻ񻣼
ÔÚµ±½ñ»¥ÁªÍøʱ´ú£¬ÍøÂçÓ¦ÓõÄÇå¾²¿É¿¿ÐÔÊÇÖÁ¹ØÖ÷ÒªµÄ¡£ÎªÁËʵÏÖÕâһĿµÄ£¬Nginx Proxy Manager£¨ÒÔϼò³ÆNPM£©Ó¦Ô˶øÉú¡£±¾ÎĽ«ÏÈÈÝNPMµÄ¼Ü¹¹Éè¼Æ£¬°üÀ¨ÊðÀí²ãÓëÖÎÀí²ãµÄÊèÉ¢¡¢¸ºÔØƽºâºÍÇå¾²Õ½ÂԵȣ¬²¢ÌṩÏà¹ØµÄ´úÂëʾÀý¡£
Ò»¡¢Ð¡Ðò
ÍøÂçÓ¦ÓõÄÇå¾²ºÍ¿É¿¿ÐÔÊÇ»¥ÁªÍøʱ´úËùÓпª·¢Õß×·ÇóµÄÄ¿µÄ¡£NPM×÷ΪһÖÖ¸ßÐÔÄܵķ´ÏòÊðÃ÷È·¾ö¼Æ»®£¬¿ÉÒÔ×ÊÖúÎÒÃÇʵÏÖÕâһĿµÄ¡£Æä¼Ü¹¹Éè¼ÆʹµÃNPM¾ß±¸ÁËÎÞаÐÔ¡¢¿ÉÀ©Õ¹ÐÔ¡¢¸ß¿ÉÓÃÐÔµÈÓŵ㣬³ÉΪ¹¹½¨Çå¾²¿É¿¿µÄÍøÂçÓ¦ÓõÄÀíÏëÑ¡Ôñ¡£
¶þ¡¢NPM¼Ü¹¹Éè¼ÆÔÔò
1.ÊðÀí²ãÓëÖÎÀí²ãµÄÊèÉ¢
ΪÁËÈ·±£ÏµÍ³µÄÇå¾²¿É¿¿ÐÔ£¬NPM½ÓÄÉÁ˽«ÊðÀí²ãºÍÖÎÀí²ã¾ÙÐÐÊèÉ¢µÄ¼Ü¹¹Éè¼Æ¡£ÊðÀí²ãÈÏÕæÎüÊպʹ¦Àí¿Í»§¶ËµÄÇëÇ󣬶øÖÎÀí²ãÔòÓÃÓÚ¶ÔÊðÀí²ã¾ÙÐÐÉèÖúͼà¿Ø¡£ÕâÖÖÊèÉ¢¿ÉÒÔÓÐÓõØÌá¸ßϵͳµÄÇå¾²ÐÔ£¬×èÖ¹ÊðÀí²ãÖ±½Ó̻¶ÓÚ¹«ÍøÖС£
2.¸ºÔØƽºâ
NPM×÷Ϊһ¸ö¸ßÐÔÄܵķ´ÏòÊðÃ÷È·¾ö¼Æ»®£¬ÐèÒª¾ß±¸¸ºÔØƽºâµÄÄÜÁ¦¡£Í¨¹ý½«ÇëÇó·Ö·¢¸ø¶à¸öÊðÀíЧÀÍÆ÷£¬¿ÉÒÔʵÏÖ¶ÔÍøÂçÁ÷Á¿µÄºÏÀí·ÖÅÉ£¬Ìá¸ßϵͳµÄÐÔÄܺͿÉÓÃÐÔ¡£NPMÄÚÖÃÁ˸ºÔØƽºâÆ÷£¬¿ÉÒÔƾ֤ÉèÖõÄÕ½ÂÔ£¬Æ½ºâ¸ºÔز¢×Ô¶¯¶ÔÇëÇó¾ÙÐÐת·¢¡£
3.Çå¾²Õ½ÂÔ
ΪÁ˱£»¤Ó¦ÓõÄÇå¾²£¬NPMÌṩÁ˶àÖÖÇå¾²Õ½ÂÔ¡£Ê×ÏÈ£¬NPMÖ§³ÖSSL/TLS¼ÓÃÜ£¬¿ÉÒÔ¶Ô¿Í»§¶ËÓëÊðÀíЧÀÍÆ÷Ö®¼äµÄͨѶ¾ÙÐмÓÃÜ£¬±ÜÃâÊý¾Ý±»ÇÔÌý¡£Æä´Î£¬NPM¿ÉÒÔ¶Ô»á¼ûÊðÀíЧÀÍÆ÷µÄÓû§¾ÙÐÐÉí·ÝÑéÖ¤£¬²¢Æ¾Ö¤Óû§µÄȨÏÞ¾ÙÐлá¼û¿ØÖÆ¡£±ðµÄ£¬NPM»¹ÌṩÁËDOS¹¥»÷·À»¤¡¢IP°×Ãûµ¥µÈ¹¦Ð§£¬½øÒ»²½Ìá¸ßÁËϵͳµÄÇå¾²ÐÔ¡£
Èý¡¢¼Ü¹¹Éè¼ÆʵÏÖ
ÒÔÏÂÊÇÒ»¸ö¼ò»¯µÄNPM¼Ü¹¹Éè¼ÆʾÀý£º
1.ÊðÀí²ã¼Ü¹¹
ÊðÀí²ãÓɶà¸öNginxЧÀÍÆ÷×é³É£¬ÕâЩЧÀÍÆ÷ͨ¹ý¸ºÔØƽºâÆ÷¾ÙÐÐÖÎÀí¡£ÊðÀí²ãµÄ¼Ü¹¹Éè¼ÆÓ¦Ö»¹Ü¼á³Ö¼òÆÓ£¬½«ÇëÇó¿ìËÙµØת·¢¸øºó¶ËÓ¦ÓÃЧÀÍÆ÷¡£ÒÔÏÂÊÇÒ»¸ö¼ò»¯µÄNginxÉèÖÃʾÀý£º
http { upstream backend { server backend1.example.com; server backend2.example.com; server backend3.example.com; } server { listen 80; location / { proxy_pass http://backend; } } }
µÇ¼ºó¸´ÖÆ
2.ÖÎÀí²ã¼Ü¹¹
ÖÎÀí²ãÓÉWeb½çÃæºÍÊý¾Ý¿â×é³É¡£Web½çÃæÓÃÓÚÉèÖÃÊðÀíЧÀÍÆ÷¡¢¼à¿Øϵͳ״̬µÈ¡£Êý¾Ý¿âÓÃÓÚ´æ´¢ÊðÀíЧÀÍÆ÷ÉèÖÃÐÅÏ¢¡¢Óû§ÐÅÏ¢µÈ¡£ÒÔÏÂÊÇÒ»¸ö¼ò»¯µÄÖÎÀí²ã¼Ü¹¹Ê¾Àý£º
from flask import Flask, request app = Flask(__name__) @app.route('/api/proxy', methods=['POST']) def create_proxy(): # ÆÊÎöÇëÇó²ÎÊý£¬½¨ÉèÊðÀíЧÀÍÆ÷ÉèÖà config = parse_config(request.json) save_config(config) @app.route('/api/proxy', methods=['DELETE']) def delete_proxy(): # ÆÊÎöÇëÇó²ÎÊý£¬É¾³ýÊðÀíЧÀÍÆ÷ÉèÖà config_id = request.json.get('id') delete_config(config_id) # Ê¡ÂÔÆäËûAPI if __name__ == '__main__': app.run()
µÇ¼ºó¸´ÖÆ
ËÄ¡¢×ܽá
Nginx Proxy ManagerÊÇÒ»¸ö¹¹½¨Çå¾²¿É¿¿µÄÍøÂçÓ¦Óõļܹ¹Éè¼Æ¼Æ»®¡£Í¨¹ýÆäÊðÀí²ãÓëÖÎÀí²ãµÄÊèÉ¢¡¢¸ºÔØƽºâºÍÇå¾²Õ½ÂÔµÈÌص㣬¿ÉÒÔʵÏÖ¸ßÐÔÄÜ¡¢¿ÉÀ©Õ¹ºÍÇå¾²µÄÍøÂçÓ¦Óᣱ¾ÎÄÌṩÁËNPM¼Ü¹¹Éè¼ÆµÄÏêϸ´úÂëʾÀý£¬Ï£Íû¶Ô¶ÁÕß¹¹½¨Çå¾²¿É¿¿µÄÍøÂçÓ¦ÓÃÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊǹ¹½¨Çå¾²¿É¿¿µÄÍøÂçÓ¦ÓãºNginx Proxy ManagerµÄ¼Ü¹¹Éè¼ÆµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡