ÔõÑùʹÓÃNginx Proxy ManagerʵÏÖ¿ìËÙ»º´æHTMLÒ³Ãæ
ÔõÑùʹÓÃNginx Proxy ManagerʵÏÖ¿ìËÙ»º´æHTMLÒ³Ãæ
СÐò£º
ÔÚÏÖ´úÍøÂçÓ¦ÓÃÖУ¬¿ìËÙ¼ÓÔØÍøÒ³ÊÇÒ»¸öÖ÷ÒªµÄÐèÇó¡£ÎªÁËÌá¸ßÓû§ÌåÑ飬ÎÒÃÇ¿ÉÒÔʹÓÃNginx Proxy ManagerÀ´ÊµÏÖ¿ìËÙ»º´æHTMLÒ³Ãæ¡£±¾ÎĽ«ÏòÄúչʾÔõÑùʹÓÃNginx Proxy ManagerÀ´ÊµÏÖÕâһĿµÄ£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£
µÚÒ»²¿·Ö£º×°ÖÃÓëÉèÖÃNginx Proxy Manager
×°ÖÃNginx Proxy Manager
Ê×ÏÈ£¬ÎÒÃÇÐèҪƾ֤¹Ù·½ÎĵµµÄָʾ£¬×°ÖÃNginx Proxy Manager¡£Äú¿ÉÒÔ´Ó¹Ù·½ÍøÕ¾ÉÏÕÒµ½ÊʺÏÄú²Ù×÷ϵͳµÄ×°Öðü£¬²¢Æ¾Ìý˵Ã÷¾ÙÐÐ×°Öá£
ÉèÖÃNginx Proxy Manager
·¿ªNginx Proxy ManagerµÄÉèÖÃÎļþ£¬Æ¾Ö¤ÄúµÄÐèÇó¾ÙÐÐÏìÓ¦µÄÉèÖá£Äú¿ÉÒÔÉèÖûº´æ¾Þϸ¡¢»º´æ·¾¶µÈ²ÎÊý£¬ÒÔÖª×ãÄúµÄÏêϸÐèÇó¡£Ò»¸öʾÀýµÄÉèÖÃƬ¶ÏÈçÏÂËùʾ£º
Á¬Ã¦Ñ§Ï°¡°Ç°¶ËÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off;
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÃæµÄʾÀýÖУ¬ÎÒÃÇÉèÖÃÁËÒ»¸öÃûΪ”my_cache”µÄ»º´æ·¾¶£¬×î´ó»º´æ¾ÞϸΪ10GB£¬»º´æʱ¼äΪ60·ÖÖÓ¡£
µÚ¶þ²¿·Ö£ºÉèÖÃNginx·´ÏòÊðÀí
ÉèÖÃNginx·´ÏòÊðÀí
ÔÚNginx Proxy ManagerµÄÉèÖÃÎļþÖУ¬ÎÒÃÇÐèÒªÉèÖ÷´ÏòÊðÀíÀ´»º´æHTMLÒ³Ãæ¡£Ò»¸öʾÀýµÄÉèÖÃƬ¶ÏÈçÏÂËùʾ£º
server { listen 80; server_name example.com; location / { proxy_pass http://backend_server; proxy_cache my_cache; proxy_cache_valid 200 5m; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; proxy_cache_revalidate on; proxy_cache_lock on; } }
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÃæµÄʾÀýÖУ¬ÎÒÃÇÉèÖÃÁËÒ»¸ö¼àÌý80¶Ë¿ÚµÄserver£¬²¢½«ËùÓÐÇëÇóͨ¹ý·´ÏòÊðÀí£¨proxy_pass£©×ª·¢µ½ÃûΪ”backend_server”µÄºó¶ËЧÀÍÆ÷¡£ÎÒÃÇ»¹ÉèÖÃÁË»º´æÃûΪ”my_cache”£¬²¢ÉèÖÃÁËÒ»¸öÓÐÓÃÆÚΪ5·ÖÖӵĻº´æÕ½ÂÔ¡£
ÖØÆôNginx Proxy Manager
µ±Nginx Proxy ManagerµÄÉèÖÃÍê³Éºó£¬ÎÒÃÇÐèÒªÖØÆôNginx Proxy ManagerÒÔʹÉèÖÃÉúЧ¡£Äú¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁîÀ´ÖØÆô£º
sudo systemctl restart nginx
µÇ¼ºó¸´ÖÆ
µÚÈý²¿·Ö£º²âÊÔ»º´æЧ¹û
»á¼ûÍøÒ³
ÏÖÔÚ£¬Äú¿ÉÒÔͨ¹ýä¯ÀÀÆ÷»á¼ûÄúµÄÍøÕ¾£¬Õý³£¼ÓÔØÄúµÄHTMLÒ³Ãæ¡£
¼ì²é»º´æ
µ±ÄúµÄÍøÒ³±»Ê״λá¼ûºó£¬Äú¿ÉÒÔͨ¹ýÉó²é»º´æ·¾¶ÖеÄÎļþÀ´È·ÈÏÍøÒ³ÊÇ·ñ±»»º´æ¡£ÀýÈ磬ÈôÊÇÎÒÃǽ«»º´æ·¾¶ÉèÖÃΪ”/path/to/cache”£¬Äú¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁîÀ´Éó²é»º´æÎļþ£º
ls /path/to/cache
µÇ¼ºó¸´ÖÆ
ÈôÊÇÄú¿´µ½ÀàËÆÓÚ”example.com/index.html”µÄÎļþ£¬ÄÇôÌåÏÖÄúµÄÍøÒ³ÒѾ±»Àֳɻº´æ¡£
²âÊÔ»º´æЧ¹û
ÏÖÔÚ£¬¹Ø±Õä¯ÀÀÆ÷²¢Ôٴλá¼ûÄúµÄÍøÒ³¡£Äú»á·¢Ã÷ÍøÒ³¼ÓÔØËÙÂʸü¿ì£¬ÕâÊÇÓÉÓÚNginx Proxy Manager»áÖ±½Ó´Ó»º´æÖзµ»ØÍøÒ³£¬¶ø²»ÊÇÏòºó¶ËЧÀÍÆ÷ÇëÇó¡£
½áÂÛ£º
ͨ¹ýʹÓÃNginx Proxy Manager£¬ÎÒÃÇ¿ÉÒÔÇáËɵØʵÏÖ¿ìËÙ»º´æHTMLÒ³Ãæ¡£±¾ÎÄÌṩÁË×°Öá¢ÉèÖúͲâÊÔµÄÏêϸ°ì·¨£¬²¢ÌṩÁËÏêϸµÄ´úÂëʾÀý£¬×ÊÖúÄú¿ìËÙ×îÏÈʵÏÖÕâһĿµÄ¡£Çëƾ֤ÄúµÄÏêϸÐèÇó¶ÔʾÀý´úÂë¾ÙÐе÷½â£¬²¢Æ¾Ö¤¹Ù·½Îĵµ¾ÙÐиü¶àµÄÉèÖúÍÓÅ»¯¡£×£ÄúÀÖ³ÉʵÏÖ¿ìËÙ»º´æHTMLÒ³Ã棡
ÒÔÉϾÍÊÇÔõÑùʹÓÃNginx Proxy ManagerʵÏÖ¿ìËÙ»º´æHTMLÒ³ÃæµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡