Question

When I'm on my development laptop, I want to go to the URL "mysite.loc" instead of "localhost:3000" for a particular project. How can I do this?

I am using Ruby on Rails 4, and the default WEBrick server.

I have tried adding "127.0.0.1 mysite.loc" to my /etc/hosts file.

Was it helpful?

Solution

Some people suggest installing Fiddler

Add your local sitename to the HOSTS file then add a custom rule to Fiddler.

static function OnBeforeRequest(oSession: Session) {  
  if (oSession.host.toLowerCase() == "mysite.loc") { 
    oSession.host = "mysite.loc:3000";
  }
}

Then when you navigate to http://mysite.loc it should be proxied to http://mysite.loc:3000.

Related questions: ServerFault StackOverflow

OTHER TIPS

You can add a definition to your /etc/hosts file, but you will still have to use port 3000 in the URL, unless you also change this to the HTTP default (80). You could, if you really wanted, just run on port 80

sudo rails s -p 80

Not that binding to port 80 generally requires su privilege - hence the use of sudo (if available).

If you want to get straight to the desired result, with the assistance of some programming magic there is

http://pow.cx/

It does some local DNS and port magic to let you do what you are wanting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top