Nginx Proxy ManagerÓë³£¼ûWebÓ¦Óÿò¼ÜµÄ¼¯³ÉÓëÓÅ»¯
Nginx Proxy ManagerÓë³£¼ûWebÓ¦Óÿò¼ÜµÄ¼¯³ÉÓëÓÅ»¯
СÐò£º
NginxÊÇÒ»¿î¸ßÐÔÄÜ¡¢ÇáÁ¿¼¶µÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷£¬¶øNginx Proxy ManagerÔòÊÇ»ùÓÚNginxµÄÒ»¸öÖÎÀí½çÃ棬ÓÃÓÚÖÎÀíºÍÉèÖÃNginxµÄÊðÀíЧÀÍ¡£ÔÚʹÓó£¼ûµÄWebÓ¦Óÿò¼ÜÈçDjango¡¢Flask¡¢LaravelµÈ¹¹½¨WebÓ¦ÓÃʱ£¬ÍŽáNginx Proxy ManagerµÄ¼¯³ÉºÍÓÅ»¯¿ÉÒÔÌáÉýÓ¦ÓõÄÐÔÄܺÍÇå¾²ÐÔ¡£±¾ÎĽ«Ì½ÌÖÔõÑù½«Nginx Proxy ManagerÓë³£¼ûWebÓ¦Óÿò¼Ü¾ÙÐм¯³É£¬²¢¸ø³öÏêϸµÄ´úÂëʾÀý¡£
Ò»¡¢Nginx Proxy ManagerµÄ×°Öúͻù±¾ÉèÖÃ
×°ÖúÍÉèÖÃNginx Proxy Manager
Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃNginx Proxy Manager£¬¿Éͨ¹ýÒÔÏÂÏÂÁîÔÚLinuxϵͳÉϾÙÐÐ×°Öãº
sudo apt-get install nginx-proxy-manager
µÇ¼ºó¸´ÖÆ
×°ÖÃÍê³Éºó£¬Ä¬ÈϵÄÉèÖÃÎļþλÓÚ/etc/nginx-proxy-manager/configĿ¼Ï£¬ÎÒÃÇ¿ÉÒÔÔÚ¸ÃÎļþÖоÙÐÐNginx Proxy ManagerµÄ»ù±¾ÉèÖã¬ÈçÖÎÀíÔ±ÃÜÂë¡¢Êý¾Ý¿âÉèÖõȡ£
½¨ÉèWebÓ¦Óÿò¼Ü
ÔÚ¼¯³ÉNginx Proxy Manager֮ǰ£¬ÎÒÃÇÐèÒªÏȽ¨ÉèÒ»¸ö»ù±¾µÄWebÓ¦Óÿò¼Ü¡£ÒÔFlask¿ò¼ÜΪÀý£¬¿ÉÒÔͨ¹ýÒÔÏ´úÂ뽨ÉèÒ»¸ö¼òÆÓµÄHello WorldÓ¦Óãº
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run()
µÇ¼ºó¸´ÖÆ
¶þ¡¢NginxÊðÀíÉèÖÃ
Ìí¼ÓÓòÃûÆÊÎö
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚNginx Proxy ManagerÖÐÌí¼ÓÓòÃûÆÊÎö£¬½«×ðÁú¿Ê±Ó¦Óûá¼û·¾¶ÓëÓòÃû°ó¶¨¡£ÔÚNginx Proxy ManagerµÄÖÎÀí½çÃæÖУ¬Ñ¡Ôñ¡°Proxy Hosts¡±£¬µã»÷¡°Add Proxy Host¡±£¬ÌîдÓòÃûºÍÓ¦ÓõÄIPµØµãºÍ¶Ë¿Ú¡£
ÉèÖ÷´ÏòÊðÀí
½ÓÏÂÀ´£¬ÎÒÃÇÐèÒªÉèÖÃNginx Proxy ManagerµÄ·´ÏòÊðÀíÉèÖ㬽«ÇëÇóת·¢µ½×ðÁú¿Ê±Ó¦Óá£ÔÚNginx Proxy ManagerµÄÖÎÀí½çÃæÖУ¬Ñ¡Ôñ¡°Proxy¡±, µã»÷¡°Add Proxy¡±£¬ÌîдÓòÃûºÍÓ¦ÓõÄIPµØµãºÍ¶Ë¿Ú¡£Í¬Ê±£¬Ñ¡Ôñ¡°Proxy Host£º¡±ÖÐÌí¼Ó֮ǰÌí¼ÓµÄÓòÃûÆÊÎö¡£
Èý¡¢ÓÅ»¯¼¯³É
ÉèÖÃHTTPS
ΪÁË°ü¹ÜÊý¾Ý´«ÊäµÄÇå¾²ÐÔ£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÉèÖÃHTTPSÀ´¼ÓÃÜͨѶ¡£ÔÚNginx Proxy ManagerµÄÖÎÀí½çÃæÖУ¬Ñ¡Ôñ¡°SSL¡±£¬µã»÷¡°Add SSL Certificate¡±£¬ÌîдÏà¹ØµÄÖ¤ÊéºÍ˽ԿÐÅÏ¢£¬²¢Óë֮ǰÉèÖõÄÓòÃû¾ÙÐа󶨡£
ÉèÖûº´æ
ΪÁËÌáÉýÓ¦ÓõĻá¼ûËÙÂÊ£¬ÎÒÃÇ¿ÉÒÔÉèÖÃNginxµÄ»º´æ¹¦Ð§¡£ÔÚNginx Proxy ManagerµÄÖÎÀí½çÃæÖУ¬Ñ¡Ôñ¡°Proxy¡±£¬µã»÷¡°Edit¡±½øÈë±à¼Ä£Ê½£¬ÕÒµ½location /²¿·Ö£¬²¢Ìí¼ÓÒÔÏ´úÂ룺
proxy_cache my_cache; proxy_cache_valid 200 1d;
µÇ¼ºó¸´ÖÆ
ÕâÑù£¬Nginx»á½«Ó¦ÓõÄÏìӦЧ¹û»º´æÒ»Ì죬´Ó¶øïÔ̶ÔÓ¦ÓõÄÇëÇó¡£
ÉèÖøºÔØƽºâ
µ±×ðÁú¿Ê±Ó¦ÓÃÐèÒª´¦Öóͷ£´ó×ڵIJ¢·¢ÇëÇóʱ£¬ÎÒÃÇ¿ÉÒÔʹÓÃNginxµÄ¸ºÔØƽºâ¹¦Ð§À´·Öµ£Ð§ÀÍÆ÷µÄ¸ºÔØ¡£ÔÚNginx Proxy ManagerµÄÖÎÀí½çÃæÖУ¬Ñ¡Ôñ¡°Proxy¡±£¬µã»÷¡°Edit¡±½øÈë±à¼Ä£Ê½£¬ÕÒµ½upstream backend²¿·Ö£¬²¢Ìí¼Ó¶à¸öÓ¦ÓõÄIPµØµãºÍ¶Ë¿Ú£¬ÀýÈ磺
server 192.168.1.101:8000; server 192.168.1.102:8000;
µÇ¼ºó¸´ÖÆ
ÕâÑù£¬Nginx»á×Ô¶¯½«ÇëÇó·Ö·¢µ½¶à¸öÓ¦ÓÃʵÀýÒÔʵÏÖ¸ºÔØƽºâ¡£
ËÄ¡¢×ܽá
ͨ¹ý½«Nginx Proxy ManagerÓë³£¼ûµÄWebÓ¦Óÿò¼Ü¼¯³É²¢¾ÙÐÐÓÅ»¯£¬ÎÒÃÇ¿ÉÒÔÌáÉýÓ¦ÓõÄÐÔÄܺÍÇå¾²ÐÔ¡£±¾ÎÄÒÔFlask¿ò¼ÜΪÀý£¬¸ø³öÁËÏêϸµÄ´úÂëʾÀý¡£ÏÖʵӦÓÃÖУ¬ÎÒÃÇ¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇóºÍ¿ò¼ÜÑ¡Ôñ¾ÙÐм¯³ÉºÍÓÅ»¯£¬ÒÔµÖ´ï×î¼ÑµÄЧ¹û¡£Ï£Íû±¾ÎÄÄܶԶÁÕßÔÚʹÓÃNginx Proxy ManagerºÍ³£¼ûWebÓ¦Óÿò¼Ü·½ÃæÌṩһЩ×ÊÖú¡£
ÒÔÉϾÍÊÇNginx Proxy ManagerÓë³£¼ûWebÓ¦Óÿò¼ÜµÄ¼¯³ÉÓëÓÅ»¯µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡