0

i've got some problems with my ruby on rails server.

It is running under localhost:3333 in my debian vm under a windows8 host.

I've installed apache2 and passengermodul for apache to get ruby. And then I've installed rails.

Now I need a subdomain wich calls the ruby on rails server.

for example admin.localhost:3333

Is something like that possible? And when how can I configurate it?

enter image description here

Felix
  • 5,452
  • 12
  • 68
  • 163

2 Answers2

2

Add custom hosts with subdomains to the hosts file, follow these steps

In your terminal, open hosts file

cd /etc
sudo nano hosts

Add the host as mentioned in the following lines to the hosts file, you can add as many as you want

127.0.0.1       admin.localhost
127.0.0.1       subdomain.localhost

Save the file, CTRL + X then press Y

Done.

To run with a custom port, specify the port number while starting the server,

rails s -p 3333

Now you can run your application with, admin.localhost:3333

Hope this helps!

Rajdeep Singh
  • 17,621
  • 6
  • 53
  • 78
  • yeah thats clear, hats what I have done already ... but whats with the port 3333? and how can I link it to my ruby on rails application running under localhost:3333 – Felix Mar 10 '15 at 12:26
  • I have edited the answer, you just need to start the rails server specifying the port number with it, `rails s -p 3333` – Rajdeep Singh Mar 10 '15 at 12:28
  • yeah how the rails server could be started is clear thanks but how do I link the subdomain admin.localhost to the localhost:3333 – Felix Mar 10 '15 at 12:29
  • Its already linked, in the hosts file I have used `127.0.0.1` which is the default address for localhost too, try using `admin.localhost:3333` it will still work – Rajdeep Singh Mar 10 '15 at 12:31
  • site isn't available ... dosn't load anyting – Felix Mar 10 '15 at 12:42
  • Please check whether it is correctly entered in `hosts` file or not because it should definitely work if everything is done perfectly – Rajdeep Singh Mar 10 '15 at 12:45
  • added a picture in my question – Felix Mar 10 '15 at 12:53
2

You can use the lvh.me domain. That domain has a DNS entry that will redirect to localhost. This also works for subdomains, so you can visit admin.lvh.me:3000 and it will redirect to localhost:3000 while still having the subdomain available in the Rails request.

The advantage is that you don't have to edit your localhost file.

zwippie
  • 15,050
  • 3
  • 39
  • 54