ÔõÑùʹÓÃNginx Proxy ManagerʵÏÖHTTPµ½HTTPSµÄ×Ô¶¯Ìøת
ÔõÑùʹÓÃNginx Proxy ManagerʵÏÖHTTPµ½HTTPSµÄ×Ô¶¯Ìøת
Ëæ×Å»¥ÁªÍøµÄÉú³¤£¬Ô½À´Ô½¶àµÄÍøÕ¾×îÏȽÓÄÉHTTPSÐÒéÀ´¼ÓÃÜ´«ÊäÊý¾Ý£¬ÒÔÌá¸ßÊý¾ÝµÄÇå¾²ÐÔºÍÓû§µÄÒþ˽±£»¤¡£ÓÉÓÚHTTPSÐÒéÐèÒªSSLÖ¤ÊéµÄÖ§³Ö£¬Òò´ËÔÚ°²ÅÅHTTPSÐÒéʱÐèÒªÓÐÒ»¶¨µÄÊÖÒÕÖ§³Ö¡£NginxÊÇÒ»¿îÇ¿Ê¢ÇÒ³£ÓõÄHTTPЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷£¬¶øNginx Proxy ManagerÊÇÒ»¸ö»ùÓÚNginxµÄ¼òÆÓÒ×ÓõÄÊðÀíÖÎÀíÆ÷£¬¿ÉÒÔʵÏÖHTTPµ½HTTPSµÄ×Ô¶¯Ìøת¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNginx Proxy ManagerÀ´ÊµÏÖÕâÒ»¹¦Ð§£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£
°ì·¨Ò»£º×°ÖÃNginx Proxy Manager
Ê×ÏÈ£¬ÐèÒªÔÚЧÀÍÆ÷ÉÏ×°ÖÃNginx Proxy Manager¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´×°Öãº
$ git clone https://github.com/jc21/nginx-proxy-manager.git $ cd nginx-proxy-manager $ docker-compose up -d
µÇ¼ºó¸´ÖÆ
Õ⽫ÔÚЧÀÍÆ÷ÉÏÆô¶¯Ò»¸öDockerÈÝÆ÷£¬ÆäÖаüÀ¨ÁËNginxЧÀÍÆ÷ºÍNginx Proxy ManagerÖÎÀí½çÃæ¡£
°ì·¨¶þ£ºÉèÖÃÓòÃûºÍSSLÖ¤Êé
½øÈëNginx Proxy ManagerÖÎÀí½çÃ棬ͨ¹ýä¯ÀÀÆ÷»á¼ûЧÀÍÆ÷µÄIPµØµã£¬Ê¹ÓÃĬÈϵÄÓû§ÃûºÍÃÜÂëµÇ¼¡£
ÔÚ½çÃæµÄ×ó²àµ¼º½À¸ÖУ¬Ñ¡Ôñ¡°Proxy Hosts¡±£¬È»ºóµã»÷¡°Ìí¼ÓÖ÷»ú¡±°´Å¥¡£ÔÚµ¯³öµÄ¶Ô»°¿òÖУ¬ÊäÈëÓòÃûÐÅÏ¢ºÍSSLÖ¤ÊéµÄÏà¹ØÐÅÏ¢¡£È·±£Ñ¡ÔñÁË¡°Force SSL¡±Ñ¡ÏîÀ´Ç¿ÖÆÆôÓÃHTTPS¡£
°ì·¨Èý£ºÉèÖÃHTTPµ½HTTPSµÄ×Ô¶¯Ìøת
ÔÚNginx Proxy ManagerÖÎÀí½çÃæÖУ¬Ñ¡Ôñ¡°Proxy Hosts¡±Ñ¡Ï²¢ÕÒµ½¸Õ¸ÕÌí¼ÓµÄÖ÷»ú¡£µã»÷Ö÷»úµÄÃû³Æ½øÈëÉèÖÃÒ³Ãæ¡£
ÔÚÉèÖÃÒ³ÃæµÄ¶¥²¿£¬ÕÒµ½¡°SSL Proxy¡±Ñ¡Ïî¡£ÔÚ¡°Redirects¡±ÏÂÀ²Ëµ¥ÖУ¬Ñ¡Ôñ¡°Redirect All Traffic to HTTPS¡±¡£
µã»÷Ò³Ãæµ×²¿µÄ¡°ÉúÑÄ¡±°´Å¥£¬ÉúÑÄÉèÖò¢Ó¦Óøü¸Ä¡£
°ì·¨ËÄ£ºÑéÖ¤ÉèÖÃÊÇ·ñÉúЧ
ÖØÐÂÆô¶¯Nginx Proxy ManagerÈÝÆ÷£¬ÒÔʹÉèÖÃÉúЧ¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´ÖØÐÂÆô¶¯ÈÝÆ÷£º
$ cd nginx-proxy-manager $ docker-compose restart
µÇ¼ºó¸´ÖÆ
È»ºó£¬Í¨¹ýä¯ÀÀÆ÷»á¼ûÉèÖõÄÓòÃû£¬ÈôÊÇÒ»ÇÐÕý³££¬»á¼û½«×Ô¶¯Ìøתµ½HTTPSÐÒ飬²¢ÇÒä¯ÀÀÆ÷µØµãÀ¸»áÏÔʾһ¸öËøͼ±ê£¬ÌåÏÖÅþÁ¬ÊÇÇå¾²µÄ¡£
´úÂëʾÀý£º
server { listen 80; server_name example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl; server_name example.com; ssl_certificate /etc/nginx/ssl/cert.pem; ssl_certificate_key /etc/nginx/ssl/key.pem; # other configuration... }
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÃæµÄʾÀýÖУ¬µÚÒ»¸öserver¿é¼àÌý80¶Ë¿Ú£¬²¢Í¨¹ýreturn 301Ö¸Áî·µ»ØÒ»¸ö301Öض¨Ïòµ½HTTPS¡£µÚ¶þ¸öserver¿é¼àÌý443¶Ë¿Ú£¬²¢ÉèÖÃÁËSSLÖ¤ÊéµÄ·¾¶£¬²¢¿ÉÒÔƾ֤ÐèÒªÌí¼ÓÆäËûµÄÉèÖá£
×ܽ᣺
ͨ¹ýʹÓÃNginx Proxy Manager£¬ÎÒÃÇ¿ÉÒÔºÜÀû±ãµØʵÏÖHTTPµ½HTTPSµÄ×Ô¶¯Ìøת¡£Ö»ÐèÒªÔÚÉèÖýçÃæÖÐÑ¡ÔñÏìÓ¦µÄÑ¡Ï¾Í¿ÉÒÔÍê³ÉÏà¹ØµÄÉèÖá£Nginx Proxy Manager²»µ«¼ò»¯ÁËHTTPSÐÒéµÄ°²ÅÅÊÂÇ飬»¹ÌṩÁËÓѺõÄÖÎÀí½çÃ棬Àû±ãÓû§¾ÙÐÐÏà¹Ø²Ù×÷¡£Ï£Íû±¾ÎÄÄܶԸ÷ÈËÃ÷È·²¢Ê¹ÓÃNginx Proxy ManagerÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃNginx Proxy ManagerʵÏÖHTTPµ½HTTPSµÄ×Ô¶¯ÌøתµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡