在静态ip上访问nodejs网站的字符串名称

String name to access nodejs website on static ip

我在内网环境下工作,一台机器有一个静态ip,10.10.10.10:3000。我在这台电脑上部署了我的nodejs服务器客户端,内网的人可以通过http://10.10.10.10:3000访问它。 我需要将其更改为 http://abawa.alladin.com:3000 之类的内容,是否可以只访问我的机器,或者我是否需要 IT 管理员的帮助?

我认为您需要联系您的 IT 管理员,因为您必须在服务器上安装 DNS。

您可以修改您的主机文件。

修改主机文件会导致本地 machine 直接查看您指定的 Internet 协议 (IP) 地址。 Rackspace 提供托管解决方案来协助处理这些资源。

10.10.10.10 www.domain.com domain.com

https://support.rackspace.com/how-to/modify-your-hosts-file/

windows路径c:\Windows\System32\Drivers\etc\hosts

linux 或 mac /etc/hosts

您可以使用 vhost

编辑 /etc/hosts:

10.10.10.10   abawa.alladin.com:3000

以下是 vhostexpress

的示例
/**
* Module dependencies.
*/
var express = require('../..');
var logger = require('morgan');
var vhost = require('vhost');

// Main server app
var main = express();

if (!module.parent) main.use(logger('dev'));

main.get('/', function(req, res){
  res.send('Hello from main app!');
});

main.get('/:sub', function(req, res){
  res.send('requested ' + req.params.sub);
});

// Redirect app
var redirect = express();

redirect.use(function(req, res){
  if (!module.parent) console.log(req.vhost);
  res.redirect('http://abawa.alladin.com:3000/' + req.vhost[0]);
});

// Vhost app
var app = module.exports = express();

app.use(vhost('*.alladin.com', redirect)); // Serves all subdomains via Redirect app
app.use(vhost('alladin.com', main)); // Serves top level domain via Main server app

/* istanbul ignore next */
if (!module.parent) {
  app.listen(3000);
  console.log('Express started on port 3000');
}