是否有一个amazon web services将翻译端口,如8001端口80端口?
我喜欢在单个静态IP地址后面托pipe多个网站,并且使用端口转发将不同端口路由到我的防火墙后面的各种networking服务器,后者进行端口转发。
如果我可以在AWS服务的某个地方实现这样的表,那将会很好:
客户端请求mydomain.com:80 – > AWS Route 53转换为123.123.123.123:8001 – >我的防火墙端口将8001转发到LAN内的Web服务器。
如果AWS不提供这项服务,那么还有另外一个开箱即用的解决scheme吗? 我可以编写自己的应用程序来执行此操作,并在EC2实例上运行它,但是如果可用的话,我更愿意使用现有的工具。
当然,AWS ALB可以做到这一点。 此外,它现在支持基于主机的路由 ,因此您可以将多个名称指向ALB,并将其configuration为分别路由每个路由。
注意:ALB只能将请求负载平衡到AWS 内的后端服务器。 这不是一个通用的负载均衡服务,可以在任何地方使用。 通常,您将在VPC的私有子网中部署后端服务器,然后在其前部署ALB以接受客户端请求。
客户端请求mydomain.com:80 – > AWS Route 53转换为123.123.123.123:8001 – >我的防火墙端口将8001转发到LAN内的Web服务器。
我想你对DNS的angular色感到困惑。 DNS对端口一无所知。 为了发布网站,DNS 只将名称映射到一个或多个IP地址。 期。 有没有办法让DNS“redirect”到一个端口或类似的东西。
我在NodeJS中编写了自己的端口转换器,并且在这里提交代码以防其他人想要使用它。 它使用https证书和纯文本端口80进行encryption连接。我在EC2 t2.micro实例上每月运行10美元,运行效果很好。
唯一需要的就是浏览器支持SNICallback,这样代理服务器就可以dynamic地为请求的域使用正确的证书。
下面的这个小应用程序利用NodeJS的http代理库 。
var proxyTable = { 'mydomain.com': 'http://localhost:8001', 'demo1.mydomain.com': 'https://localhost:8002', // https after proxy 'demo2.mydomain.com': 'https://localhost:8005', // https after proxy 'demo3.mydomain.com': 'https://localhost:8006', // https after proxy 'demo4.mydomain.com': 'https://localhost:8007', // https after proxy 'demo5.mydomain.com': 'https://localhost:8008', // https after proxy } http.createServer(function(req, res) { var hostname = req.headers.host.replace(/^www\./, ''); // remove www. subdomain prefix if (proxyTable[hostname]) { if (-1 != httpsDomains.indexOf(hostname)) { // redirect to https for httpsDomains redirectToHttps(req, res); // res.redirect() not available here } else { proxy.web(req, res, {target: proxyTable[hostname]}); } } else { displayError(res, hostname) } }).listen(80); // Use SNICallback to dynamically use various SSL certificates depending upon hostname. // To add a new SSL domain, add to secureContext AND proxyTable const efboKey = fs.readFileSync(global.appRootPath + '/../mydomain.com.key', 'utf8'); const efboCert = fs.readFileSync(global.appRootPath + '/../mydomain.com.crt', 'utf8'); const efboCaBundleArray = makeCertificateAuthorityArray(global.appRootPath + '/../mydomain.com.ca-bundle', 'utf8'); const efboHttpsComponents = { key: efboKey, cert: efboCert, ca: efboCaBundleArray, }; var secureContext = { 'mydomain.com': tls.createSecureContext(efboHttpsComponents), 'demo1.mydomain.com': tls.createSecureContext(efboHttpsComponents), 'demo2.mydomain.com': tls.createSecureContext(efboHttpsComponents), 'demo3.mydomain.com': tls.createSecureContext(efboHttpsComponents), 'demo4.mydomain.com': tls.createSecureContext(efboHttpsComponents), 'demo5.mydomain.com': tls.createSecureContext(efboHttpsComponents), } try { var options = { SNICallback: function (hostname, cb) { if (secureContext[hostname]) { if (cb) { cb(null, secureContext[hostname]); } else { return secureContext[hostname]; // compatibility for older versions of node } } else { throw new Error('No keys/certificates for hostname requested'); } }, // must list a key and cert because required by tls.createServer() key: efboKey, cert: efboCert, ca: efboCaBundleArray, } https.createServer(options, function (req, res) { var hostname = req.headers.host.replace(/^www\./, ''); // remove www. subdomain prefix proxy.web(req, res, {target: proxyTable[hostname], secure: false}); // proxy https to http }).listen(443); } catch (err){ console.error(err.message); console.error(err.stack); }