ÔõÑùʹÓÃNginx Proxy ManagerʵÏÖÍøÂçÁ÷Á¿¿ØÖÆ
ÔõÑùʹÓÃNginx Proxy ManagerʵÏÖÍøÂçÁ÷Á¿¿ØÖÆ
¸ÅÊö£º
ÍøÂçÁ÷Á¿¿ØÖÆÊÇָͨ¹ý¶ÔÍøÂçÁ÷Á¿¾ÙÐÐÖÎÀíºÍ¿ØÖÆ£¬ÒÔµÖ´ïÓÅ»¯ÍøÂçÐÔÄÜ£¬°ü¹ÜÍøÂçЧÀÍÖÊÁ¿µÄÄ¿µÄ¡£Nginx Proxy ManagerÊÇÒ»¸ö»ùÓÚNginxµÄÊðÀíЧÀÍÆ÷ÖÎÀí¹¤¾ß£¬Í¨¹ýʹÓÃËü£¬ÎÒÃÇ¿ÉÒÔÀû±ãµØʵÏÖÍøÂçÁ÷Á¿¿ØÖÆ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNginx Proxy ManagerÀ´ÊµÏÖÍøÂçÁ÷Á¿¿ØÖÆ£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£
°ì·¨Ò»£º×°ÖÃNginx Proxy Manager
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚÎÒÃǵÄЧÀÍÆ÷ÉÏ×°ÖúÍÉèÖÃNginx Proxy Manager¡£ÒÔÏÂÊÇ×°Öð취£º
×°ÖÃNode.js£ºÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁî×°ÖÃNode.js£º
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt-get install -y nodejs
µÇ¼ºó¸´ÖÆ
×°ÖÃNginx Proxy Manager£ºÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁî×°ÖÃNginx Proxy Manager£º
sudo npm install -g npm@latest sudo npm install -g pm2 git clone https://github.com/jc21/nginx-proxy-manager.git cd nginx-proxy-manager npm ci
µÇ¼ºó¸´ÖÆ
Æô¶¯Nginx Proxy Manager£ºÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁîÆô¶¯Nginx Proxy Manager£º
pm2 start ecosystem.config.js pm2 save
µÇ¼ºó¸´ÖÆ
°ì·¨¶þ£º½¨ÉèÊðÀíЧÀÍÆ÷
·¿ªNginx Proxy ManagerµÄWeb½çÃ棬ÔÚä¯ÀÀÆ÷ÖÐÊäÈëЧÀÍÆ÷µÄIPµØµãºÍ¶Ë¿ÚºÅ£¬ÀýÈ磺http://localhost:81¡£
µã»÷¡°Proxy Hosts¡±Ñ¡Ï£¬È»ºóµã»÷¡°Add Proxy Host¡±°´Å¥¡£
ÌîдÏà¹ØÐÅÏ¢£¬°üÀ¨ÓòÃû¡¢Ä¿µÄURLºÍ»á¼ûÏÞÖƵȡ£
µã»÷¡°Save¡±°´Å¥ÉúÑÄÉèÖá£
°ì·¨Èý£ºÉèÖÃÁ÷Á¿¿ØÖÆ
·¿ªNginx Proxy ManagerµÄWeb½çÃ棬ÔÚä¯ÀÀÆ÷ÖÐÊäÈëЧÀÍÆ÷µÄIPµØµãºÍ¶Ë¿ÚºÅ£¬ÀýÈ磺http://localhost:81¡£
µã»÷¡°Proxy Hosts¡±Ñ¡Ï£¬È»ºóµã»÷ÒªÉèÖÃÁ÷Á¿¿ØÖƵÄÊðÀíЧÀÍÆ÷¡£
ÔÚÊðÀíЧÀÍÆ÷µÄÏêÇéÒ³ÃæÉÏ£¬ÕÒµ½¡°Proxy Rules¡±²¿·Ö£¬µã»÷¡°Add Proxy Rule¡±°´Å¥¡£
ÌîдÏà¹ØÐÅÏ¢£¬°üÀ¨¹æÔòÃû³Æ¡¢Æ¥Åä·¾¶ºÍÏÞÖÆÑ¡ÏîµÈ¡£
µã»÷¡°Save¡±°´Å¥ÉúÑÄÉèÖá£
´úÂëʾÀý£º
ÒÔÏÂÊÇÒ»¸öʹÓÃNginx Proxy ManagerʵÏÖ¼òÆÓÁ÷Á¿¿ØÖƵÄʾÀý´úÂ룺
location / { limit_req zone=my_zone burst=5 nodelay; proxy_pass http://backend; } location /status { stub_status on; }
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÊöʾÀýÖУ¬ÎÒÃÇʹÓÃÁËNginxµÄlimit_reqÄ£¿éÀ´¿ØÖÆÇëÇóÁ÷Á¿¡£ÏÞÖÆÇøÓò£¨zone£©±»ÉèÖÃΪ¡°my_zone¡±£¬²¢ÉèÖÃÁËÏÞÖÆËÙÂÊΪ5´Î/Ãë¡£µ±Áè¼ÝÏÞÖÆËÙÂÊʱ£¬ÇëÇ󽫱»ÑÓ³Ù£¨nodelayΪfalse£©»òÁ¬Ã¦·µ»Ø429 Too Many RequestsÏìÓ¦£¨nodelayΪtrue£©¡£Í¬Ê±£¬ÎÒÃÇ»¹Í¨¹ýÉèÖ÷´ÏòÊðÀí£¨proxy_pass£©½«ÇëÇóת·¢µ½ºó¶ËЧÀÍÆ÷¡£
×ܽ᣺
ʹÓÃNginx Proxy Manager¿ÉÒÔÀû±ãµØʵÏÖÍøÂçÁ÷Á¿¿ØÖÆ£¬Ìá¸ßÍøÂçÐÔÄܺÍЧÀÍÖÊÁ¿¡£Í¨¹ý½¨ÉèÊðÀíЧÀÍÆ÷ºÍÉèÖÃÁ÷Á¿¿ØÖƹæÔò£¬ÎÒÃÇ¿ÉÒÔƾ֤ÐèÒª¶ÔÍøÂçÁ÷Á¿¾ÙÐÐÖÎÀíºÍ¿ØÖÆ¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏÈÈÝÁËÔõÑù×°ÖúÍÉèÖÃNginx Proxy Manager£¬²¢ÌṩÁËÏêϸµÄ´úÂëʾÀýÀ´ÑÝʾÔõÑùʵÏÖÁ÷Á¿¿ØÖÆ¡£Ï£Íû±¾ÎĶÔÄãÓÐËù×ÊÖú£¡
ÒÔÉϾÍÊÇÔõÑùʹÓÃNginx Proxy ManagerʵÏÖÍøÂçÁ÷Á¿¿ØÖƵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡