¹¹½¨Çå¾²¿É¿¿µÄÈÝÆ÷ЧÀÍ£ºÊ¹ÓÃNginx Proxy ManagerʵÏÖÁ÷Á¿¸ôÀë
¹¹½¨Çå¾²¿É¿¿µÄÈÝÆ÷ЧÀÍ£ºÊ¹ÓÃNginx Proxy ManagerʵÏÖÁ÷Á¿¸ôÀë
Ëæ×ÅÔÆÅÌËãºÍÈÝÆ÷»¯ÊÖÒÕµÄÒ»Ö±Éú³¤£¬Ô½À´Ô½¶àµÄÆóÒµºÍ¿ª·¢Õß×îÏÈʹÓÃÈÝÆ÷À´ÍйܺÍÖÎÀíËûÃǵÄÓ¦ÓóÌÐò¡£¶øΪÁË°ü¹ÜÈÝÆ÷ЧÀ͵ÄÇå¾²¿É¿¿£¬Á÷Á¿¸ôÀëÊÇÒ»¸ö²»¿É»òȱµÄ»·½Ú¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNginx Proxy Manager£¨ÒÔϼò³ÆNPM£©À´¹¹½¨Çå¾²¿É¿¿µÄÈÝÆ÷ЧÀÍ£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£
NPMÏÈÈÝ
NPMÊÇÒ»¸ö»ùÓÚNginxµÄÊðÀíÖÎÀí¹¤¾ß£¬ËüÌṩÁËÒ»¸öÓû§ÓѺõĽçÃ棬¿ÉÒÔ¿ìËÙÉèÖúÍÖÎÀí·´ÏòÊðÀí¡¢¸ºÔØƽºâ¡¢SSLÖ¤ÊéµÈ¹¦Ð§¡£Í¨¹ýNPM£¬ÎÒÃÇ¿ÉÒÔʵÏÖ¶ÔÈÝÆ÷ЧÀ͵ÄÁ÷Á¿¸ôÀ룬Ìá¸ßÇå¾²ÐԺͿɿ¿ÐÔ¡£
×°ÖúÍÉèÖÃNPM
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚЧÀÍÆ÷ÉÏ×°ÖÃNPM¡£ÇëÈ·±£ÄãµÄЧÀÍÆ÷ÒѾװÖÃÁËNginx£¬²¢ÇÒ¿ªÆôÁËDocker¹¦Ð§¡£
½ÓÏÂÀ´£¬Ê¹ÓÃÒÔÏÂÏÂÁî×°ÖÃNPM£º
docker run --restart always -d -p 81:81 -p 443:443 -v npmdata:/data -v /var/run/docker.sock:/var/run/docker.sock jlesage/nginx-proxy-manager
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁÔÚЧÀÍÆ÷ÉÏÆô¶¯Ò»¸öNPMÈÝÆ÷£¬²¢½«¶Ë¿Ú81ºÍ443Ó³Éäµ½Ö÷»úµÄ¶ÔÓ¦¶Ë¿ÚÉÏ¡£
Æô¶¯Íê³Éºó£¬Ê¹ÓÃä¯ÀÀÆ÷»á¼ûЧÀÍÆ÷IPµØµã£¬¼ÓÉ϶˿ںÅ81£¨ÀýÈ磺http://server_ip:81£©£¬½øÈëNPMµÄÖÎÀí½çÃæ¡£
ÉèÖÃÈÝÆ÷ЧÀÍ
ÔÚNPMµÄÖÎÀí½çÃ棬ÎÒÃÇ¿ÉÒÔÀû±ãµØÉèÖúÍÖÎÀíÈÝÆ÷ЧÀÍ¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʾÀý£º
Ê×ÏÈ£¬ÔÚNPM½çÃæµÄ×ó²àµ¼º½À¸ÖУ¬µã»÷¡°Proxy Hosts¡±£¬È»ºóµã»÷¡°Add Proxy Host¡±°´Å¥¡£
ÔÚµ¯³öµÄ´°¿ÚÖУ¬ÌîдÒÔÏÂÐÅÏ¢£º
Domain Names: ÊäÈëÄãµÄÓòÃû£¬ÓÃÓÚ»á¼ûÈÝÆ÷ЧÀÍ¡£
Scheme: Ñ¡ÔñÐÒéÀàÐÍ£¬Ò»Ñùƽ³£Ñ¡Ôñ¡°http¡±»ò¡°https¡±¡£
Forward Hostname/IP: ÊäÈëÈÝÆ÷ЧÀ͵ÄIPµØµã»òÖ÷»úÃû³Æ¡£
Forward Port: ÊäÈëÈÝÆ÷ЧÀ͵Ķ˿ںš£
µã»÷¡°Save¡±ÉúÑÄÉèÖá£
SSLÖ¤ÊéÉèÖÃ
ΪÁË°ü¹ÜÊý¾Ý´«ÊäµÄÇå¾²ÐÔ£¬ÎÒÃÇ»¹¿ÉÒÔÉèÖÃSSLÖ¤Êé¡£ÔÚNPMµÄÖÎÀí½çÃ棬µã»÷¡°SSL Certificates¡±£¬È»ºóµã»÷¡°Add Certificate¡±°´Å¥¡£
ÔÚµ¯³öµÄ´°¿ÚÖУ¬ÌîдÒÔÏÂÐÅÏ¢£º
Domain: ÊäÈëÄãµÄÓòÃû¡£
E-Mail: ÊäÈëÄãµÄÓÊÏäµØµã£¬ÓÃÓÚÖ¤ÊéÏà¹Ø֪ͨ¡£
µã»÷¡°Save¡±ÉúÑÄÉèÖá£
ʾÀý´úÂëʵÏÖ
ÒÔÏÂÊÇÒ»¸ö»ùÓÚDockerµÄNode.jsÓ¦ÓõÄʾÀý´úÂ룬ÑÝʾÁËÔõÑùÔÚÈÝÆ÷ÇéÐÎÏÂʹÓÃNPMʵÏÖÁ÷Á¿¸ôÀ룺
const express = require('express'); const app = express(); const port = 3000; app.get('/', (req, res) => { res.send('Hello World!'); }); app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`); });
µÇ¼ºó¸´ÖÆ
ͨ¹ýÒÔÉÏ´úÂ룬ÎÒÃǽ¨ÉèÁËÒ»¸ö¼òÆÓµÄExpressÓ¦Ó㬼àÌý¶Ë¿Ú3000£¬²¢·µ»Ø¡°Hello World!¡±¡£
½«¸ÃÓ¦Óôò°ü³ÉDocker¾µÏñ£¬²¢ÔÚNPMÖÐÉèÖÃÏìÓ¦µÄÊðÀíÉèÖ㬼´¿ÉʵÏÖ»ùÓÚNPMµÄÁ÷Á¿¸ôÀë¡£
×ܽá
ͨ¹ýʹÓÃNginx Proxy Manager£¬ÎÒÃÇ¿ÉÒÔ¹¹½¨Çå¾²¿É¿¿µÄÈÝÆ÷ЧÀÍ£¬ÊµÏÖ¶ÔÈÝÆ÷ЧÀ͵ÄÁ÷Á¿¸ôÀë¡£NPMÌṩÁËÓû§ÓѺõĽçÃ棬ʹµÃÉèÖúÍÖÎÀíÈÝÆ÷ЧÀͱäµÃ¼òÆÓÒ×Óá£Í¬Ê±£¬Í¨¹ýSSLÖ¤ÊéµÄÉèÖã¬ÎÒÃÇ¿ÉÒÔ°ü¹ÜÊý¾Ý´«ÊäµÄÇå¾²ÐÔ¡£
ÒÔÉÏÊǹØÓÚÔõÑùʹÓÃNginx Proxy ManagerʵÏÖÁ÷Á¿¸ôÀëµÄÏÈÈݺʹúÂëʾÀý¡£Ï£Íû±¾ÎÄÄܹ»×ÊÖúµ½Äã¹¹½¨Çå¾²¿É¿¿µÄÈÝÆ÷ЧÀÍ¡£
ÒÔÉϾÍÊǹ¹½¨Çå¾²¿É¿¿µÄÈÝÆ÷ЧÀÍ£ºÊ¹ÓÃNginx Proxy ManagerʵÏÖÁ÷Á¿¸ôÀëµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡