How to change the url (from localhostL:3000) to (example.com)

I am new to ruby on rails and running rails 2.3.5.My application is
running at localhost:3000 ,but i want it should be run at
example.com” in brower when i start the serve normally as “script/
server” .
What to do?

Thanks

Open your /etc/hosts file in Linux. Windows is the same hosts file under
some other directory.
Any how puts the next line in the file
127.0.0.1 example.com
Then if you “ping example.com” IP 127.0.0.1 will respond.
now you can use example.com:3000 to access your web site.
If you are not happy with your 3000 port then change Rails default http
port
setting.
I don’t know how to change this port number.

On Mon, Apr 18, 2011 at 5:51 AM, amrit pal pathak
<[email protected]

Open your /etc/hosts file in Linux. Windows is the same hosts file under
some other directory.
Any how puts the next line in the file
127.0.0.1 example.com
Then if you “ping example.com” IP 127.0.0.1 will respond.
now you can use example.com:3000 to access your web site.
If you are not happy with your 3000 port then change Rails default http
port
setting.
I don’t know how to change this port number.

It’s possible with iptables.
Try out these rules:

sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -d 127.0.0.0/8 -j
REDIRECT
–to-port 3000
sudo iptables -t nat -A OUTPUT -p tcp --dport 8080 -d 127.0.0.0/8 -j
REDIRECT --to-port 80

First rule will redirect all local traffic from 80 to 3000.
The second will redirect 8080 to 80, to allow you access phpmyadmin or
whatever you have on 80 port.

Tested on Ubuntu.

On Tue, Apr 19, 2011 at 10:57 AM, amrit pal pathak <
[email protected]> wrote:

   Thanks .It helped me.

–to-port 3000
without port number 3000?
If yes,what to do next?

Here you go. Amazing what you find on the Internet these days.

http://tinyurl.com/3bp7nsh

B.

On Apr 19, 4:09am, Alexander [email protected] wrote:

Open your /etc/hosts file in Linux. Windows is the same hosts file under
some other directory.
Any how puts the next line in the file
127.0.0.1 example.com
Then if you “ping example.com” IP 127.0.0.1 will respond.
now you can use example.com:3000 to access your web site.

   Thanks .It helped me.

REDIRECT --to-port 80

First rule will redirect all local traffic from 80 to 3000.
The second will redirect 8080 to 80, to allow you access phpmyadmin or
whatever you have on 80 port.

Tested on Ubuntu.

 Both exectued sussfully.Now can i access,rails application

without port number 3000?
If yes,what to do next?

Thanks

On Wed, Apr 20, 2011 at 11:31 AM, amrit pal pathak <
[email protected]> wrote:

Then if you “ping example.com” IP 127.0.0.1 will respond.
Try out these rules:
whatever you have on 80 port.
It tells to run the app on different ports,but i want to run it
without giving any port like at “example.com

Basics of the internet. http requests default to port 80. example.com is
responding on port 80. Set you app to run on port 80.

B.

On Apr 20, 2011, at 12:31 PM, amrit pal pathak wrote:

Here you go. Amazing what you find on the Internet these days.

http://tinyurl.com/3bp7nsh
It tells to run the app on different ports,but i want to run it
without giving any port like at “example.com

That’s an implementation detail. All of the (non-secure) Web sites you
visit that don’t show a port use the default port 80.

If you want to be completely pedantic, the URL for the Apple home page
is http://www.apple.com:80/index.html. But when you type in
www.apple.com
, your browser first takes the leap of faith that you mean http://
(since it is a browser, after all) and then further assumes that you
mean port 80, because you didn’t top your URL with https:// or tail
the domain with :443. Then, because you didn’t enter a filename, the
Apache server (or whatever they use there) looks up the DefaultIndex
and fills that in for you, and performs a silent redirect (it doesn’t
tell you the exact details, so it could just as easily be index.php or
index.erb or anything at all) to whatever that actual index file is,
and THEN starts filling the sub-requests contained in that index file.

You can read a lot more about this at the Apache site, in the httpd
project documentation. Pick the version you use there, and read up on
mod_rewrite and its cousins.

Short answer, you can do this, it’s done every day, and it’s not that
difficult. Slightly longer answer, you still haven’t given any good
reason why you would want to do this in the development environment.
But have you looked at http://pow.cx/ for no-config local network
hosting with a “real” domain?

Walter

On Apr 20, 8:51am, Bryan C. [email protected] wrote:

[email protected]> wrote:

If you are not happy with your 3000 port then change Rails default http
sudo iptables -t nat -A OUTPUT -p tcp --dport 8080 -d 127.0.0.0/8 -j
If yes,what to do next?

Here you go. Amazing what you find on the Internet these days.

http://tinyurl.com/3bp7nsh
It tells to run the app on different ports,but i want to run it
without giving any port like at “example.com

Start your rails server with http default port 80:
rails server -p 80
Now example.com should work.
I don’t why people write three pages of information without answering
you
anything :slight_smile:

On Tue, Apr 19, 2011 at 11:57 AM, amrit pal pathak <

Thanks Alex, that helps a lot :slight_smile: Simple isn’t it rails server -p 80 :stuck_out_tongue:
Thanks again, any idea how I can achieve subdomains like basecamp
does? username.basecamphq.com

On Apr 20, 12:55pm, Walter Lee D. [email protected] wrote:

and THEN starts filling the sub-requests contained in that index file.

Pow is just for Mac .I am running ubuntu 10.04,so unable to install
and config it .
Any solution?alternative?

Thanks

Manoj,

I am glad that worked for you.

Take a look at this railscast for rails 3 subdomains
http://railscasts.com/episodes/221-subdomains-in-rails-3

Thanks,
Alex

http://railscasts.com/episodes/221-subdomains-in-rails-3

I didn’t read all the basic DNS questions, but hopefully somebody
pointed out that example.com won’t be accessible externally.

Sent from my iPhone

On Apr 21, 2011, at 10:54 AM, Alex K. [email protected] wrote:

Start your rails server with http default port 80:
rails server -p 80
Now example.com should work.
I don’t why people write three pages of information without answering you
anything :slight_smile:

Because if you give a man a fish you feed him for a day. If you teach
him to fish you feed him for life. The answer was in all the information
provided and so was the answers to all the basic follow up questions.

B.

On Apr 21, 11:54am, Alex K. [email protected] wrote:

Start your rails server with http default port 80:
rails server -p 80
Now example.com should work.
I don’t why people write three pages of information without answering you
anything :slight_smile:

  Thank you very much.
   It helped

[2011-04-22 09:20:06] WARN TCPServer Error: Permission denied -
from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize’
from script/server:3

why?

Linux/un*x systems require root privileges in order for a process to
bind to
“privileged” ports (any port number lower than 1024 (which is why rails
and
most other “development” and “testing” -mode processes use
higher-numbered
ports like 3000).

If you really want to run your rails app on port 80 using the command
above,
you’ll likely need to use “sudo”: sudo script/server -p 8

However, if you’re using RVM to manage your ruby and rubygems
collections
then you’d use its sudo wrapper “rvmsudo” that retains your “ruby
environment” settings.

On Apr 22, 7:58am, amrit pal pathak [email protected]
wrote:

On Apr 21, 11:54am, Alex K. [email protected] wrote:

Start your rails server with http default port 80:
rails server -p 80
Now example.com should work.
I don’t why people write three pages of information without answering you
anything :slight_smile:

   i dont know why but "script/server -p 80" gives error me now as

[email protected]:~/amritdemo$ script/server -p 80

=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:80
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-04-22 09:20:01] INFO WEBrick 1.3.1
[2011-04-22 09:20:01] INFO ruby 1.8.7 (2010-01-10) [i486-linux]
[2011-04-22 09:20:06] WARN TCPServer Error: Permission denied -
bind(2)
Exiting
/usr/lib/ruby/1.8/webrick/utils.rb:73:in initialize': Permission denied - bind(2) (Errno::EACCES) from /usr/lib/ruby/1.8/webrick/utils.rb:73:innew’
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in create_listeners' from /usr/lib/ruby/1.8/webrick/utils.rb:70:ineach’
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in create_listeners' from /usr/lib/ruby/1.8/webrick/server.rb:75:inlisten’
from /usr/lib/ruby/1.8/webrick/server.rb:63:in initialize' from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:ininitialize’
from /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/
webrick.rb:10:in new' from /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/ webrick.rb:10:inrun’
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:
111
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from script/server:3

why?

Thanks

Edit the host file of your os to make example.com point a 127.0.0.1

this’ll do it.

basically redirects port 80 to port 3000

sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -d 127.0.0.1/8 -j
REDIRECT --to-port 3000

tested and works

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs