ÔõÑùʹÓÃNginx Proxy Manager´î½¨¸ßЧµÄ·´ÏòÊðÀíЧÀÍÆ÷
ÔõÑùʹÓÃNginx Proxy Manager´î½¨¸ßЧµÄ·´ÏòÊðÀíЧÀÍÆ÷
Ëæ×Å»¥ÁªÍøµÄÉú³¤£¬Ô½À´Ô½¶àµÄÍøÂçÓ¦ÓÃÐèҪͨ¹ý·´ÏòÊðÀíЧÀÍÆ÷À´ÌṩЧÀÍ¡£Nginx Proxy ManagerÊÇÒ»¸ö¹¦Ð§Ç¿Ê¢ÇÒÒ×ÓÚʹÓõŤ¾ß£¬Ëü¿ÉÒÔ×ÊÖúÎÒÃÇ¿ìËٴºÍÖÎÀí·´ÏòÊðÀíЧÀÍÆ÷¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNginx Proxy Manager´î½¨¸ßЧµÄ·´ÏòÊðÀíЧÀÍÆ÷£¬²¢¸ø³öÏêϸµÄ´úÂëʾÀý¡£
Ò»¡¢×°ÖÃNginx Proxy Manager
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚЧÀÍÆ÷ÉÏ×°ÖÃNginx Proxy Manager¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´×°Öãº
# ×°ÖÃNode.js curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt-get install -y nodejs # ¿Ë¡Nginx Proxy ManagerµÄ´úÂë¿â git clone https://github.com/jc21/nginx-proxy-manager.git # ½øÈë´úÂë¿âĿ¼ cd nginx-proxy-manager # ×°ÖÃÒÀÀµ npm ci # ÔËÐÐNginx Proxy Manager npm start
µÇ¼ºó¸´ÖÆ
ÀÖ³É×°ÖÃNginx Proxy ManagerÖ®ºó£¬¿ÉÒÔͨ¹ý»á¼ûЧÀÍÆ÷µÄIPµØµã¼ÓÉÏĬÈϵĶ˿Ú8888À´½øÈëÖÎÀí½çÃæ¡£
¶þ¡¢Ìí¼ÓÓòÃûºÍSSLÖ¤Êé
ÔÚNginx Proxy ManagerµÄÖÎÀí½çÃæÖУ¬µã»÷×ó²àµÄ”Proxy Hosts”£¬È»ºóµã»÷ÓÒÉϽǵĔAdd Proxy Host”°´Å¥£¬×îÏÈÌí¼ÓÒ»¸öеÄÊðÀíÖ÷»ú¡£
ÔÚµ¯³öµÄ¶Ô»°¿òÖУ¬Ìîд”Subdomain”ºÍ”Domain”×ֶΣ¬ÕâÊÇÄãÒªÊðÀíµÄÓòÃû¡£Í¬Ê±£¬Ñ¡ÔñÒ»¸öÒѾÉèÖúõÄSSLÖ¤Êé¡£
Èý¡¢ÉèÖÃÊðÀí¹æÔò
ÔÚÌí¼ÓÍêÊðÀíÖ÷»úÖ®ºó£¬ÎÒÃÇÐèҪΪÓòÃûÉèÖÃÊðÀí¹æÔò¡£µã»÷¸Õ¸ÕÌí¼ÓµÄÊðÀíÖ÷»ú£¬È»ºóµã»÷”Proxy Rules”Ñ¡Ï£¬×îÏÈÉèÖÃÊðÀí¹æÔò¡£
µã»÷ÓÒÉϽǵĔAdd Proxy Rule”°´Å¥£¬Ìîд”Source URL”×ֶκ͔Destination URL”×ֶΡ£”Source URL”ÊÇ¿Í»§¶ËÇëÇóµÄURL£¬”Destination URL”ÊÇ·´ÏòÊðÀíЧÀÍÆ÷½«ÇëÇóת·¢µ½µÄURL¡£ÀýÈ磬ÈôÊÇÎÒÃÇÒª½«ËùÓÐÒÔ/api¿ªÍ·µÄÇëÇóת·¢µ½http://localhost:3000£¬Ôò¿ÉÒÔÌîд/apiΪ”Source URL”£¬http://localhost:3000Ϊ”Destination URL”¡£
ËÄ¡¢Ó¦ÓÃÉèÖò¢Æô¶¯ÊðÀíЧÀÍÆ÷
Íê³ÉÊðÀí¹æÔòµÄÉèÖÃÖ®ºó£¬µã»÷ÓÒÉϽǵĔSave”°´Å¥À´ÉúÑÄÉèÖá£È»ºó£¬µã»÷ÓÒÉϽǵĔApply Config”°´Å¥À´Ó¦ÓÃÉèÖá£
ÉèÖÃÓ¦ÓÃÀÖ³ÉÖ®ºó£¬¿ÉÒÔͨ¹ý»á¼ûЧÀÍÆ÷µÄIPµØµã¼ÓÉÏ֮ǰÉèÖõÄÓòÃûÀ´»á¼û·´ÏòÊðÀíЧÀÍÆ÷¡£
Îå¡¢´úÂëʾÀý
ÏÂÃæÊÇÒ»¸öʹÓÃNginx Proxy Manager´î½¨¸ßЧ·´ÏòÊðÀíЧÀÍÆ÷µÄʾÀý´úÂ룺
const http = require('http'); // ½¨ÉèÒ»¸öhttpЧÀÍÆ÷ const server = http.createServer((req, res) => { // ÔÚÕâÀï´¦ÀíÓªÒµÂß¼ res.end('Hello, World!'); }); // ¼àÌý¶Ë¿Ú server.listen(3000, () => { console.log('Server started on port 3000'); });
µÇ¼ºó¸´ÖÆ
Áù¡¢×ܽá
ͨ¹ýNginx Proxy Manager£¬ÎÒÃÇ¿ÉÒÔ¿ìËٴºÍÖÎÀí¸ßЧµÄ·´ÏòÊðÀíЧÀÍÆ÷¡£Ö»ÐèÒª¼òÆÓµÄÉèÖÃÊðÀíÖ÷»úºÍÊðÀí¹æÔò£¬¾Í¿ÉÒÔΪ²î±ðµÄÓòÃû»òÕß·¾¶ÉèÖòî±ðµÄ·´ÏòÊðÀí¹æÔò¡£Í¬Ê±£¬Nginx Proxy Manager»¹ÌṩÁ˶àÖÖ¹¦Ð§£¬ÈçSSLÖ¤ÊéµÄÖÎÀíºÍHTTPÇëÇóµÄÈÕÖ¾¼Í¼µÈ¡£ÐÅÍÐͨ¹ý±¾ÎĵÄÏÈÈÝ£¬ÄãÒѾÕÆÎÕÁËÔõÑùʹÓÃNginx Proxy Manager´î½¨¸ßЧµÄ·´ÏòÊðÀíЧÀÍÆ÷µÄÒªÁ죬ϣÍû¶ÔÄãÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃNginx Proxy Manager´î½¨¸ßЧµÄ·´ÏòÊðÀíЧÀÍÆ÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡