Nginx Proxy ManagerÉèÖÃÆÊÎöÓëÓÅ»¯
Nginx Proxy ManagerÉèÖÃÆÊÎöÓëÓÅ»¯
¸ÅÊö£º
Nginx Proxy ManagerÊÇÒ»¸ö»ùÓÚNginxµÄ·´ÏòÊðÀíÖÎÀí¹¤¾ß£¬¿ÉÒÔ×ÊÖúÎÒÃÇÀû±ãµØÉèÖúÍÖÎÀí·´ÏòÊðÀíЧÀÍÆ÷¡£ÔÚʹÓÃNginx Proxy ManagerµÄÀú³ÌÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ý¶ÔÆäÉèÖþÙÐÐÆÊÎöÓëÓÅ»¯£¬Ìá¸ßЧÀÍÆ÷µÄÐÔÄÜÓëÇå¾²ÐÔ¡£
ÉèÖÃÆÊÎö£º
ÉèÖÃÎļþλÖúͽṹ£º
Nginx Proxy ManagerµÄÉèÖÃÎļþλÓÚ/etc/nginx/conf.dĿ¼Ï£¬Ã¿¸ö·´ÏòÊðÀíµÄÉèÖÃÎļþÒÔ.conf×îºó¡£ÔÚÉèÖÃÎļþÖУ¬Ö÷Òª°üÀ¨ÁËÊðÀíЧÀÍÆ÷µÄIPµØµã¡¢¶Ë¿ÚºÅ¡¢ÓòÃûµÈÐÅÏ¢¡£
»ù±¾ÉèÖÃÏîÆÊÎö£º
ÔÚÉèÖÃÎļþÖУ¬ÎÒÃÇ¿ÉÒÔ¿´µ½Ò»Ð©»ù±¾µÄÉèÖÃÏÈçÏÂËùʾ£º
server {
listen 80; server_name example.com; location / { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; }
µÇ¼ºó¸´ÖÆ
}
ÆäÖУ¬listenÖ¸¶¨¼àÌýµÄ¶Ë¿ÚºÅ£»server_nameÖ¸¶¨ÓòÃû£»locationÖ¸¶¨URL·¾¶£»proxy_passÖ¸¶¨×ª·¢µ½µÄºó¶ËЧÀÍÆ÷µØµã£»proxy_set_headerÖ¸¶¨ÉèÖÃÇëÇóÍ·ÐÅÏ¢¡£
¸ß¼¶ÉèÖÃÏîÆÊÎö£º
ÔÚNginx Proxy ManagerµÄÉèÖÃÎļþÖУ¬Ò²Ö§³ÖһЩ¸ß¼¶µÄÉèÖÃÏÀ´ÓÅ»¯Ð§ÀÍÆ÷µÄÐÔÄܺÍÇå¾²ÐÔ¡£ÒÔÏÂΪһЩ³£¼ûµÄ¸ß¼¶ÉèÖÃÏ
keepalive_timeout£ºÉèÖÃÓëºó¶ËЧÀÍÆ÷µÄÅþÁ¬µÄ¼á³Öʱ¼ä£¬Ä¬ÒÔΪ75s¡£¿ÉÒÔÊʵ±µ÷½â¸ÃÖµÀ´Ìá¸ßÐÔÄÜ¡£
worker_connections£ºÉèÖÃÿ¸öÊÂÇéÀú³ÌµÄ×î´óÅþÁ¬Êý£¬Ä¬ÒÔΪ1024¡£¿ÉÒÔÊʵ±µ÷½â¸ÃÖµÀ´Ìá¸ßÐÔÄÜ¡£
client_max_body_size£ºÉèÖÃÎüÊÕ¿Í»§¶ËÇëÇóµÄ×î¸ÅÂÔ»ý£¬Ä¬ÒÔΪ1m¡£¿ÉÒÔƾ֤ÏÖʵÐèÇóÀ´ÉèÖýϴóµÄÖµ£¬ÒÔÖ§³Ö´óÎļþµÄÉÏ´«¡£
limit_req_zone£ºÉèÖÃÏÞÖÆÇëÇóµÄËÙÂʺÍÅþÁ¬Êý£¬ÒÔ±ÜÃâ¶ñÒâÇëÇóºÍDDoS¹¥»÷¡£
SSL/TLSÉèÖãº
Nginx Proxy Manager»¹Ö§³ÖSSL/TLSµÄÉèÖã¬ÒÔÌṩÇå¾²µÄͨѶ¡£ÒÔÏÂÊÇһЩ³£¼ûµÄSSL/TLSÉèÖÃÏ
server {
listen 443 ssl; server_name example.com; ssl_certificate /etc/nginx/ssl/cert.crt; ssl_certificate_key /etc/nginx/ssl/cert.key; location / { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; }
µÇ¼ºó¸´ÖÆ
}
ÆäÖУ¬ssl_certificateºÍssl_certificate_keyÖ¸¶¨SSLÖ¤ÊéµÄ·¾¶¡£Í¨¹ýÉèÖÃSSL/TLS£¬ÎÒÃÇ¿ÉÒÔ±£»¤¿Í»§¶ËÓëÊðÀíЧÀÍÆ÷Ö®¼äµÄÊý¾Ý´«ÊäÇå¾²¡£
ÉèÖÃÓÅ»¯£º
ΪÁ˽øÒ»²½Ìá¸ßNginx Proxy ManagerµÄÐÔÄܺÍÇå¾²ÐÔ£¬ÎÒÃÇ¿ÉÒÔ¾ÙÐÐһЩÓÅ»¯ÉèÖá£
»º´æÉèÖãº
Nginx Proxy ManagerÖ§³ÖHTTP»º´æÉèÖ㬿ÉÒÔ½«¾³£»á¼ûµÄ¾²Ì¬×ÊÔ´»º±£´æÍâµØ£¬ÒÔïÔÌÏìӦʱ¼äºÍ´ø¿íÕ¼Óá£ÒÔÏÂÊÇһЩ³£¼ûµÄ»º´æÉèÖÃÏ
server {
listen 80; server_name example.com; location / { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_cache my_cache; proxy_cache_valid 200 1h; } location ~* .(css|js|gif|jpg|jpeg|png)$ { proxy_cache my_cache; proxy_cache_valid 200 1d; } location ~* .(woff|ttf|svg|eot)$ { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_cache my_cache; proxy_cache_valid 200 30d; }
µÇ¼ºó¸´ÖÆ
}
ÆäÖУ¬proxy_cacheÖ¸¶¨»º´æÃû³Æ£¬proxy_cache_validÖ¸¶¨»º´æµÄÓÐÓÃʱ¼ä¡£
¸ºÔØƽºâÉèÖãº
ΪÁËÌá¸ßЧÀÍÆ÷µÄÐÔÄܺͿÉÓÃÐÔ£¬ÎÒÃÇ¿ÉÒÔʹÓÃNginx Proxy ManagerµÄ¸ºÔØƽºâ¹¦Ð§£¬½«ÇëÇó·Ö·¢µ½¶à¸öºó¶ËЧÀÍÆ÷ÉÏ¡£ÒÔÏÂÊÇһЩ³£¼ûµÄ¸ºÔØƽºâÉèÖÃÏ
upstream backend {
server backend1.example.com; server backend2.example.com; server backend3.example.com;
µÇ¼ºó¸´ÖÆ
}
ÆäÖУ¬backend1¡¢backend2ºÍbackend3Ϊºó¶ËЧÀÍÆ÷µÄµØµã¡£
Çå¾²ÉèÖãº
ΪÁËÌá¸ßЧÀÍÆ÷µÄÇå¾²ÐÔ£¬ÎÒÃÇ¿ÉÒÔʹÓÃNginx Proxy ManagerµÄÇå¾²ÉèÖÃÏÈçÒÔÏÂËùʾ£º
server {
listen 80; server_name example.com; location / { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_hide_header X-Powered-By; proxy_hide_header Server; proxy_next_upstream error timeout http_503; }
µÇ¼ºó¸´ÖÆ
}
ÆäÖУ¬proxy_set_headerÖ¸¶¨ÇëÇóÍ·ÐÅÏ¢£¬proxy_hide_headerÖ¸¶¨Òþ²ØµÄÏìӦͷÐÅÏ¢£¬proxy_next_upstreamÖ¸¶¨ÔÚÓöµ½¹ýʧ¡¢³¬Ê±»òhttp_503ʱ£¬¼ÌÐøÏòÏÂÒ»¸öºó¶ËЧÀÍÆ÷ת·¢ÇëÇó¡£
½áÓ
ͨ¹ý¶ÔNginx Proxy ManagerµÄÉèÖþÙÐÐÆÊÎöÓëÓÅ»¯£¬ÎÒÃÇ¿ÉÒÔÌá¸ßЧÀÍÆ÷µÄÐÔÄܺÍÇå¾²ÐÔ¡£ÔÚÏÖʵӦÓÃÖУ¬¿ÉÒÔƾ֤ÐèÇó¾ÙÐÐÊʵ±µÄÉèÖõ÷½â£¬²¢ÔÚ²âÊÔÇéÐÎÖоÙÐвâÊÔºÍÑéÖ¤¡£Ï£Íû±¾ÆªÎÄÕÂÄܹ»¶Ô¸÷ÈËÔÚʹÓÃNginx Proxy ManagerʱÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇNginx Proxy ManagerÉèÖÃÆÊÎöÓëÓÅ»¯µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡