×ðÁú¿­Ê±¹ÙÍøµÇ¼

¹¹½¨ÂþÑÜʽϵͳ£ºÊ¹ÓÃNginx Proxy ManagerʵÏÖЧÀÍ·¢Ã÷Óë·ÓÉ

¹¹½¨ÂþÑÜʽϵͳ£ºÊ¹ÓÃNginx Proxy ManagerʵÏÖЧÀÍ·¢Ã÷Óë·ÓÉ

¸ÅÊö£º

ÔÚÏÖ´úµÄÂþÑÜʽϵͳÖУ¬Ð§ÀÍ·¢Ã÷ºÍ·ÓÉÊǺÜÊÇÖ÷ÒªµÄ¹¦Ð§¡£Ð§ÀÍ·¢Ã÷ÔÊÐíϵͳ×Ô¶¯·¢Ã÷ºÍ×¢²á¿ÉÓõÄЧÀÍʵÀý£¬¶ø·ÓÉÔòÈ·±£ÇëÇóÄܹ»×¼È·µØת·¢µ½ÏìÓ¦µÄЧÀÍʵÀý¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÏÈÈÝÔõÑùʹÓÃNginx Proxy Manager¹¹½¨Ò»¸ö¼òÆÓ¶øÇ¿Ê¢µÄЧÀÍ·¢Ã÷ºÍ·Óɽâ¾ö¼Æ»®£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£

ÏàʶNginx Proxy Manager

Nginx Proxy ManagerÊÇÒ»¸ö»ùÓÚNginxµÄÊðÀíЧÀÍÆ÷ÖÎÀíÆ÷£¬ËüÌṩÁËÒ»¸öÒ×ÓÚʹÓõÄWeb½çÃæÀ´ÉèÖúÍÖÎÀí·´ÏòÊðÀíЧÀÍÆ÷¡£ËüÖ§³ÖHTTP¡¢HTTPS¡¢TCPºÍUDPµÄÊðÀí£¬¿ÉÒÔʵÏÖÇëÇóµÄ¸ºÔØƽºâºÍSSLÖÕÖ¹µÈ¹¦Ð§¡£

×°ÖúÍÉèÖÃNginx Proxy Manager

Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃNginx Proxy Manager¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´×°ÖÃËü£º

npm install -g nginx-proxy-manager

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´Æô¶¯Nginx Proxy Manager£º

npm start

µÇ¼ºó¸´ÖÆ

Æô¶¯ºó£¬¿ÉÒÔͨ¹ýä¯ÀÀÆ÷»á¼û http://localhost:81 À´·­¿ªNginx Proxy ManagerµÄWeb½çÃæ¡£Ê״λá¼ûʱ£¬ÐèÒªÉèÖÃÖÎÀíÔ±Óû§ÃûºÍÃÜÂë¡£

ÉèÖÃЧÀÍ·¢Ã÷

ÔÚNginx Proxy ManagerµÄWeb½çÃæÖУ¬¿ÉÒÔͨ¹ýÌí¼Ó¡°Upstreams¡±À´ÉèÖÃЧÀÍ·¢Ã÷¡£Ã¿¸öUpstream´ú±íÒ»¸öЧÀÍ£¬Ëü°üÀ¨¶à¸öʵÀý£¨½Úµã£©¡£ÔÚÿ¸öUpstreamÖУ¬¿ÉÒÔÖ¸¶¨ÊµÀýµÄIPµØµãºÍ¶Ë¿ÚºÅ¡£

ÒÔÏÂÊÇÒ»¸öʾÀýUpstreamµÄÉèÖãº

Name: my_service
Servers:
- Name: server1
  Address: 192.168.0.1:8000
- Name: server2
  Address: 192.168.0.2:8000

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÉèÖÃÖУ¬ÎÒÃǽ¨ÉèÁËÒ»¸öÃûΪmy_serviceµÄUpstream£¬°üÀ¨ÁËÁ½¸öʵÀý£¬»®·ÖÊÇ192.168.0.1:8000ºÍ192.168.0.2:8000¡£

ÉèÖ÷ÓÉ

ÔÚNginx Proxy ManagerµÄWeb½çÃæÖУ¬¿ÉÒÔͨ¹ýÌí¼Ó¡°Proxy Hosts¡±À´ÉèÖ÷ÓÉ¡£Ã¿¸öProxy Host´ú±íÒ»¸ö·ÓɹæÔò£¬Ëü½ç˵ÁËÇëÇóµÄȪԴºÍÄ¿µÄ¡£

ÒÔÏÂÊÇÒ»¸öʾÀýProxy HostµÄÉèÖãº

Domain Name: mydomain.com
Path: /myroute
Upstream: my_service

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÉèÖÃÖУ¬ÎÒÃǽ¨ÉèÁËÒ»¸ö½«ËùÓÐÀ´×Ômydomain.com/myrouteµÄÇëÇóת·¢µ½my_service UpstreamµÄ·ÓɹæÔò¡£

ʹÓÃʾÀý´úÂë

ΪÁËÑÝʾNginx Proxy ManagerµÄʹÓã¬ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄNode.jsʾÀý´úÂ룬ÓÃÀ´Æô¶¯Ò»¸öHTTPЧÀÍÆ÷£¬²¢½«Æä×÷ΪЧÀ͵ÄÒ»¸öʵÀý×¢²áµ½Nginx Proxy Manager£º

const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello, world!');
});

app.listen(8000, () => {
  console.log('Server is running on http://localhost:8000');
  // TODO: Register the server with Nginx Proxy Manager
});

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʾÀý´úÂëÖУ¬ÎÒÃÇÆô¶¯ÁËÒ»¸ö¼àÌýÔÚ8000¶Ë¿ÚµÄHTTPЧÀÍÆ÷¡£ÎªÁ˽«¸ÃЧÀÍ×¢²áµ½Nginx Proxy Manager£¬ÐèÒªÔÚÆô¶¯Ð§ÀÍÆ÷µÄ»Øµ÷º¯ÊýÖÐÌí¼ÓÏìÓ¦µÄ×¢²á´úÂë¡£

¿ÉÒÔʹÓÃNginx Proxy ManagerÌṩµÄAPIÀ´ÊµÏÖ×¢²áºÍ×¢ÏúЧÀÍʵÀý¡£ÒÔÏÂÊÇÒ»¸öʾÀý´úÂ룬ÓÃÓÚ×¢²áЧÀÍʵÀýµ½Nginx Proxy Manager£º

const axios = require('axios');

const registerInstance = async (name, address) => {
  try {
    await axios.post('http://localhost:81/api/proxy/host', {
      name,
      target: address,
    });
    console.log(`Instance ${name} registered successfully`);
  } catch (error) {
    console.error(`Failed to register instance ${name}`, error);
  }
};

// Register the server instance with Nginx Proxy Manager
registerInstance('server1', 'http://192.168.0.1:8000');

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʾÀý´úÂëÖУ¬ÎÒÃÇʹÓÃÁËaxios¿âÀ´·¢ËÍHTTPÇëÇó¡£Í¨¹ýŲÓÃregisterInstanceº¯Êý£¬½«ÊµÀýÃû³ÆºÍµØµãת´ï¸øNginx Proxy ManagerµÄAPIÀ´×¢²áЧÀÍʵÀý¡£ÐèҪȷ±£APIÇëÇóµÄµØµãÓëNginx Proxy ManagerµÄÏÖʵµØµãÒ»Ö¡£

ͨ¹ýÔÚ¶à¸öЧÀÍÆ÷ÉÏÔËÐÐÕâ¸öʾÀý´úÂ룬¿ÉÒÔ½«ËüÃÇ×¢²áΪЧÀ͵ÄʵÀý£¬²¢Ê¹ÓÃNginx Proxy ManagerÀ´ÊµÏÖЧÀÍ·¢Ã÷ºÍ·ÓÉ¡£

×ܽ᣺

ͨ¹ýʹÓÃNginx Proxy ManagerÀ´¹¹½¨ÂþÑÜʽϵͳµÄЧÀÍ·¢Ã÷ºÍ·Óɹ¦Ð§£¬¿ÉÒÔ¼ò»¯ÏµÍ³µÄÉèÖúÍÖÎÀí£¬Ìá¸ßϵͳµÄ¿É¿¿ÐԺͿÉÉìËõÐÔ¡£±¾ÎÄÏÈÈÝÁËNginx Proxy ManagerµÄ×°ÖúÍÉèÖÃÒªÁ죬²¢ÌṩÁËÏêϸµÄ´úÂëʾÀýÀ´ÑÝʾÔõÑù×¢²áЧÀÍʵÀýºÍÉèÖ÷ÓɹæÔò¡£¶ÁÕß¿ÉÒÔƾ֤ÏÖʵÐèÇó½øÒ»³ÌÐòÕûºÍÀ©Õ¹ÕâЩ´úÂëʾÀý£¬ÒÔÖª×ã×Ô¼ºµÄÂþÑÜʽϵͳµÄÐèÇó¡£

ÒÔÉϾÍÊǹ¹½¨ÂþÑÜʽϵͳ£ºÊ¹ÓÃNginx Proxy ManagerʵÏÖЧÀÍ·¢Ã÷Óë·ÓɵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ