Ethan Turkeltaub
Ethan Turkeltaub

Reputation: 2961

Alias for IP address?

I'm deploying a Ruby project over a network with Nginx. The way you access the web-interface of the project is going to the server's IP address with the port (192.168.1.113:3000). This is rather cumbersome. How could I use a location such as http://clock.local?

Upvotes: 0

Views: 2452

Answers (3)

Alex Howansky
Alex Howansky

Reputation: 53626

If you only need to to resolve from one or two machines, just put the alias in /etc/hosts. Otherwise, if you've got a local private DNS server, you can add your desired name there so that it's available to everybody on the LAN. I'd also build a proxy on port 80 so that you don't need to specify the port. (Assuming port 80 on that machine isn't already being used.)

Edit: I take that back, it does't matter if 80 is already being used, you can proxy by vhost:

server {
  server_name whatever.whatever;
  root /path/to/doc_root
  location / {
    proxy_pass http://localhost:3000;
    proxy_set_header X-Forwarded-For $remote_addr;
  }
}

Upvotes: 1

Ricardo
Ricardo

Reputation: 172

Usually operating systems have a "hosts" file where you can set a name that points to an IP. That's where "localhost" is specified (at least for me).

Anyway, I think you can set an alias to the IP there, but the port won't work. I guess you'll still need to specify it manually. So it'll be http://alias:3000/.

Upvotes: 1

Alok
Alok

Reputation: 542

Not familiar with nginx, but why can't you just add an entry into /etc/hosts (or WINDIR/system32/drivers/etc/hosts) to resolve the IP address to a user defined alias?

Upvotes: 1

Related Questions