WEBrick for a local application?

Hello!

I'm considering writing a dream journaling program for a small group
of friends, and we're on different platforms. I'm on Linux, one is on
FreeBSD, and others are on WindowsXP. Basically, I wanted to do
something that would yield a nice cross-platform GUI. I've looked at
using Tk, but I know that on the Linux/BSD platforms, it's rather
ugly. I thought about making a Web based gui for the program, since I
could use CSS and such to really make the interface look nice.

I've looked at the WEBrick docs and samples, and, it looks like it
could yield a decent solution. I've played around with it a little,
and I realized that starting it up at all makes an open port to the
outside world if you're online. That isn't exactly what I wanted to
do.

My main question, I guess, is this: Is there any way that I can use
WEBrick in a local setting only that will not open up a persons
computer to the outside world? I think that it could make a nice
application base, but I don't want to compromise one's security while
using it.

I really wanted to keep downloads for these people to be kept to a
minimum, so I didn't really want to make them download a bunch of
extra GUI libraries. I also wanted something that would run fairly
quick, and would be easy to use. (for some reason I have had a hard
time grasping Fox, although Tk was easy enough)

Am I barking up the wrong tree with this?

Thanks,
Jeremy

Hi,

Hello!

I'm considering writing a dream journaling program for a small group
of friends, and we're on different platforms. I'm on Linux, one is on
FreeBSD, and others are on WindowsXP. Basically, I wanted to do
something that would yield a nice cross-platform GUI. I've looked at
using Tk, but I know that on the Linux/BSD platforms, it's rather
ugly. I thought about making a Web based gui for the program, since I
could use CSS and such to really make the interface look nice.

I've looked at the WEBrick docs and samples, and, it looks like it
could yield a decent solution. I've played around with it a little,
and I realized that starting it up at all makes an open port to the
outside world if you're online. That isn't exactly what I wanted to
do.

My main question, I guess, is this: Is there any way that I can use
WEBrick in a local setting only that will not open up a persons
computer to the outside world? I think that it could make a nice
application base, but I don't want to compromise one's security while
using it.

I really wanted to keep downloads for these people to be kept to a
minimum, so I didn't really want to make them download a bunch of
extra GUI libraries. I also wanted something that would run fairly
quick, and would be easy to use. (for some reason I have had a hard
time grasping Fox, although Tk was easy enough)

Am I barking up the wrong tree with this?

WEBrick rocks.

You can use :BindAddress => local_ip and it will be LAN accessible only. Like:

:BindAddress => 192.168.0.100, :Port => 2000

See its code, as I use Wee and its a bit different, like:
Wee::WEBrickAdaptor.register('/app' => app).start(:BindAddress =>
'192.168.0.100', :Port => 2000)

Cheers,
Joao

···

On Mon, 7 Mar 2005 11:41:05 +0900, Jeremy Bear <jeremy.bear@gmail.com> wrote:

My main question, I guess, is this: Is there any way that I can use
WEBrick in a local setting only that will not open up a persons
computer to the outside world? I think that it could make a nice
application base, but I don't want to compromise one's security while
using it.

Bind the webserver to the 127.0.0.1 IP address and it will be only
accesible from the local host

Web-based applications are very common nowadays, I don't think anyone
will be surprised by that.

cheers,
                    vruz

Hello!

I'm considering writing a dream journaling program for a small group
of friends, and we're on different platforms. I'm on Linux, one is on
FreeBSD, and others are on WindowsXP. Basically, I wanted to do
something that would yield a nice cross-platform GUI. I've looked at
using Tk, but I know that on the Linux/BSD platforms, it's rather
ugly.

Ruby has GTK and Qt APIs too.

I've looked at the WEBrick docs and samples, and, it looks like it
could yield a decent solution.

I'd suggest looking at Rails. It's a very elegant ruby-based web development
solution that can be used to create simple database front ends VERY quickly.
For example, if you wanted a simple log of entries by different users, that
would mean adding a table to a database, running about four commands to setup
rails, editing two files with a few lines of text, and you're done.
Obviously, you have more work to do if you want to customise the looks etc.,
but it's basically what you'd expect to be doing. Just feels "right" to
me :slight_smile:

It's also WEBrick based, but has the option of using Apache etc. too. Either
way, there's no problem with running it (or any other web-based solution) on
a private LAN, if you need too. As others have said, you just pick and
internal IP. Even a normal web server with access control would work, if
you're desperate. And there's the secondary layer of a firewall to limit
access too.

···

On Monday 07 March 2005 02:41, Jeremy Bear wrote:

--
Lee.

Hi,

Hi,

> Hello!
>
> I'm considering writing a dream journaling program for a small group
> of friends, and we're on different platforms. I'm on Linux, one is on
> FreeBSD, and others are on WindowsXP. Basically, I wanted to do
> something that would yield a nice cross-platform GUI. I've looked at
> using Tk, but I know that on the Linux/BSD platforms, it's rather
> ugly. I thought about making a Web based gui for the program, since I
> could use CSS and such to really make the interface look nice.
>
> I've looked at the WEBrick docs and samples, and, it looks like it
> could yield a decent solution. I've played around with it a little,
> and I realized that starting it up at all makes an open port to the
> outside world if you're online. That isn't exactly what I wanted to
> do.
>
> My main question, I guess, is this: Is there any way that I can use
> WEBrick in a local setting only that will not open up a persons
> computer to the outside world? I think that it could make a nice
> application base, but I don't want to compromise one's security while
> using it.
>
> I really wanted to keep downloads for these people to be kept to a
> minimum, so I didn't really want to make them download a bunch of
> extra GUI libraries. I also wanted something that would run fairly
> quick, and would be easy to use. (for some reason I have had a hard
> time grasping Fox, although Tk was easy enough)
>
> Am I barking up the wrong tree with this?

WEBrick rocks.

You can use :BindAddress => local_ip and it will be LAN accessible only. Like:

:BindAddress => 192.168.0.100, :Port => 2000

See its code, as I use Wee and its a bit different, like:
Wee::WEBrickAdaptor.register('/app' => app).start(:BindAddress =>
'192.168.0.100', :Port => 2000)

I could have asked, do you know Wee already? It's very capable in
delivering Web-Apps. After a day or so you will have your solution
partly done already.

See: http://rubyforge.org/projects/wee/

WEBrick is its main backend so far.

Cheers,
Joao

···

On Sun, 6 Mar 2005 23:47:49 -0300, Joao Pedrosa <joaopedrosa@gmail.com> wrote:

On Mon, 7 Mar 2005 11:41:05 +0900, Jeremy Bear <jeremy.bear@gmail.com> wrote:

> My main question, I guess, is this: Is there any way that I can use
> WEBrick in a local setting only that will not open up a persons
> computer to the outside world?

WEBrick rocks.

You can use :BindAddress => local_ip and it will be LAN accessible only. Like:

:BindAddress => 192.168.0.100, :Port => 2000

See its code, as I use Wee and its a bit different, like:
Wee::WEBrickAdaptor.register('/app' => app).start(:BindAddress =>
'192.168.0.100', :Port => 2000)

Ah, okay. This seems simple enough. My question regarding this,
though, is: What if I don't know what they have their local IP set to?
Does it need to match their IP, or is there a more "generic" one I
can use, such as the 127.0.0.1 address that vruz mentioned, that will
work no matter what for the local host?

Thanks all for the extremely quick responses!

Jeremy

127.0.0.1 is the standard loopback address, it works on windows and unix,
and most other places as well.

···

On Mon, 7 Mar 2005 12:09:09 +0900, Jeremy Bear <jeremy.bear@gmail.com> wrote:

> > My main question, I guess, is this: Is there any way that I can use
> > WEBrick in a local setting only that will not open up a persons
> > computer to the outside world?
>
> WEBrick rocks.
>
> You can use :BindAddress => local_ip and it will be LAN accessible only. Like:
>
> :BindAddress => 192.168.0.100, :Port => 2000
>
> See its code, as I use Wee and its a bit different, like:
> Wee::WEBrickAdaptor.register('/app' => app).start(:BindAddress =>
> '192.168.0.100', :Port => 2000)

Ah, okay. This seems simple enough. My question regarding this,
though, is: What if I don't know what they have their local IP set to?
Does it need to match their IP, or is there a more "generic" one I
can use, such as the 127.0.0.1 address that vruz mentioned, that will
work no matter what for the local host?

--
spooq

127.0.01 is the IP for 'localhost' (ie: "this machine"), so it's a
safe bet that.
The only time I could see it being an issue is if they're already
running another server of some kind on the same port (unlikely).

···

On Mon, 7 Mar 2005 12:09:09 +0900, Jeremy Bear <jeremy.bear@gmail.com> wrote:

> > My main question, I guess, is this: Is there any way that I can use
> > WEBrick in a local setting only that will not open up a persons
> > computer to the outside world?
>
> WEBrick rocks.
>
> You can use :BindAddress => local_ip and it will be LAN accessible only. Like:
>
> :BindAddress => 192.168.0.100, :Port => 2000
>
> See its code, as I use Wee and its a bit different, like:
> Wee::WEBrickAdaptor.register('/app' => app).start(:BindAddress =>
> '192.168.0.100', :Port => 2000)

Ah, okay. This seems simple enough. My question regarding this,
though, is: What if I don't know what they have their local IP set to?
Does it need to match their IP, or is there a more "generic" one I
can use, such as the 127.0.0.1 address that vruz mentioned, that will
work no matter what for the local host?

--
Bill Guindon (aka aGorilla)

Hi,

···

On Mon, 7 Mar 2005 12:09:09 +0900, Jeremy Bear <jeremy.bear@gmail.com> wrote:

> > My main question, I guess, is this: Is there any way that I can use
> > WEBrick in a local setting only that will not open up a persons
> > computer to the outside world?
>
> WEBrick rocks.
>
> You can use :BindAddress => local_ip and it will be LAN accessible only. Like:
>
> :BindAddress => 192.168.0.100, :Port => 2000
>
> See its code, as I use Wee and its a bit different, like:
> Wee::WEBrickAdaptor.register('/app' => app).start(:BindAddress =>
> '192.168.0.100', :Port => 2000)

Ah, okay. This seems simple enough. My question regarding this,
though, is: What if I don't know what they have their local IP set to?
Does it need to match their IP, or is there a more "generic" one I
can use, such as the 127.0.0.1 address that vruz mentioned, that will
work no matter what for the local host?

127.0.0.1 is suitable as well, but this is accessible from the same
machine only. The 192.168.0.100 approach is useful if you need the
same WEBrick shared in a LAN, as if all the three of you were somehow
connected in the same LAN, but I guess not.

Cheers,
Joao

Ah, okay. This seems simple enough. My question regarding this,
though, is: What if I don't know what they have their local IP set to?
Does it need to match their IP, or is there a more "generic" one I
can use, such as the 127.0.0.1 address that vruz mentioned, that will
work no matter what for the local host?

yes, 127.0.0.1 is your safest bet.

It won't be useful if you need to access the app from other machines
in the local network though.

If you need the app to be accessible from other machines in the local
network you may have to detect the available local addresses
(generally something in the 192.168.xxx.xxx range)
but that detection is probably system-dependent.

cheers,
                         vruz

Bill Guindon wrote:

···

On Mon, 7 Mar 2005 12:09:09 +0900, Jeremy Bear <jeremy.bear@gmail.com> wrote:

My main question, I guess, is this: Is there any way that I can use
WEBrick in a local setting only that will not open up a persons
computer to the outside world?
       

WEBrick rocks.

You can use :BindAddress => local_ip and it will be LAN accessible only. Like:

:BindAddress => 192.168.0.100, :Port => 2000

See its code, as I use Wee and its a bit different, like:
Wee::WEBrickAdaptor.register('/app' => app).start(:BindAddress =>
'192.168.0.100', :Port => 2000)
     

Ah, okay. This seems simple enough. My question regarding this,
though, is: What if I don't know what they have their local IP set to?
Does it need to match their IP, or is there a more "generic" one I
can use, such as the 127.0.0.1 address that vruz mentioned, that will
work no matter what for the local host?
   
127.0.01 is the IP for 'localhost' (ie: "this machine"), so it's a
safe bet that.
The only time I could see it being an issue is if they're already
running another server of some kind on the same port (unlikely).

Is Webrick can be use for single point of entry (every request served by index.rb).

regards
Eko

Eko,

The concept makes sense, but I have to admit that finding
documentation for WEBrick has been... challenging. Could you
elaborate on this a bit? What do you mean by a single point of entry?

Thanks,
Jeremy

···

On Mon, 7 Mar 2005 12:22:51 +0900, Eko Budi Setiyo <contact_us@haltebis.com> wrote:

Bill Guindon wrote:

>On Mon, 7 Mar 2005 12:09:09 +0900, Jeremy Bear <jeremy.bear@gmail.com> wrote:
>
>
>>>>My main question, I guess, is this: Is there any way that I can use
>>>>WEBrick in a local setting only that will not open up a persons
>>>>computer to the outside world?
>>>>
>>>>
>>>WEBrick rocks.
>>>
>>>You can use :BindAddress => local_ip and it will be LAN accessible only. Like:
>>>
>>>:BindAddress => 192.168.0.100, :Port => 2000
>>>
>>>See its code, as I use Wee and its a bit different, like:
>>>Wee::WEBrickAdaptor.register('/app' => app).start(:BindAddress =>
>>>'192.168.0.100', :Port => 2000)
>>>
>>>
>>Ah, okay. This seems simple enough. My question regarding this,
>>though, is: What if I don't know what they have their local IP set to?
>> Does it need to match their IP, or is there a more "generic" one I
>>can use, such as the 127.0.0.1 address that vruz mentioned, that will
>>work no matter what for the local host?
>>
>>
>
>127.0.01 is the IP for 'localhost' (ie: "this machine"), so it's a
>safe bet that.
>The only time I could see it being an issue is if they're already
>running another server of some kind on the same port (unlikely).
>
>
>
Is Webrick can be use for single point of entry (every request served by
index.rb).

Jeremy Bear wrote:

Bill Guindon wrote:

My main question, I guess, is this: Is there any way that I can use
WEBrick in a local setting only that will not open up a persons
computer to the outside world?

WEBrick rocks.

You can use :BindAddress => local_ip and it will be LAN accessible only. Like:

:BindAddress => 192.168.0.100, :Port => 2000

See its code, as I use Wee and its a bit different, like:
Wee::WEBrickAdaptor.register('/app' => app).start(:BindAddress =>
'192.168.0.100', :Port => 2000)

Ah, okay. This seems simple enough. My question regarding this,
though, is: What if I don't know what they have their local IP set to?
Does it need to match their IP, or is there a more "generic" one I
can use, such as the 127.0.0.1 address that vruz mentioned, that will
work no matter what for the local host?

127.0.01 is the IP for 'localhost' (ie: "this machine"), so it's a
safe bet that.
The only time I could see it being an issue is if they're already
running another server of some kind on the same port (unlikely).

Is Webrick can be use for single point of entry (every request served by
index.rb).
   
Eko,

The concept makes sense, but I have to admit that finding
documentation for WEBrick has been... challenging. Could you
elaborate on this a bit? What do you mean by a single point of entry?

Thanks,
Jeremy

Actually, I believe in the single point of entry power.
I used it in FuseLogic(php) and QLogic (ruby). index.php or index.rb will decide which module will be executed base on the user response (REQUES_URI).
One example of the benefit among the others is, lets say I change my hosting company and some how the install ruby on difference path. What I have to do is just change
the first line from #!/bin/ruby to #!/user/bin/ruby (this is example only!) in the index.rb

The reason I ask is I already try to use Webrick and doesn't do what I want.
What happen to my scripts is, lets say I already use my browser to hit http://127.0.0.1/index.rb/init/version than after that I hit http://127.0.0.1/index.rb/bittorrents/main ,
Webrick will always give the same result as http://127.0.0.1/index.rb/init/version

I really want to use webrick also for my RubyToday project

May be I am doing some thing wrong here. I don't know

Regards
Eko

···

On Mon, 7 Mar 2005 12:22:51 +0900, Eko Budi Setiyo ><contact_us@haltebis.com> wrote:

On Mon, 7 Mar 2005 12:09:09 +0900, Jeremy Bear <jeremy.bear@gmail.com> wrote:

Actually, I believe in the single point of entry power.
I used it in FuseLogic(php) and QLogic (ruby). index.php or index.rb
will decide which module will be executed base on the user response
(REQUES_URI).
One example of the benefit among the others is, lets say I change my
hosting company and some how the install ruby on difference path. What I
have to do is just change
the first line from #!/bin/ruby to #!/user/bin/ruby (this is example
only!) in the index.rb
The reason I ask is I already try to use Webrick and doesn't do what I
want.
What happen to my scripts is, lets say I already use my browser to hit
http://127.0.0.1/index.rb/init/version than after that I hit
http://127.0.0.1/index.rb/bittorrents/main ,
Webrick will always give the same result as
http://127.0.0.1/index.rb/init/version

I really want to use webrick also for my RubyToday project

May be I am doing some thing wrong here. I don't know

Regards
Eko

Jeremy, the confusion arises because Eko is asking about a completely
different , unrelated, problem in this thread.

Eko, maybe if you post some source code to look at ?

That will make it way much easier to find what's your your problem about

cheers,
                      vruz

What are you doing in index.rb? I'd think a simple 'include' would do
it after you parse the URI, but I could be missing something.

···

On Mon, 7 Mar 2005 12:54:39 +0900, Eko Budi Setiyo <contact_us@haltebis.com> wrote:

Actually, I believe in the single point of entry power.
I used it in FuseLogic(php) and QLogic (ruby). index.php or index.rb
will decide which module will be executed base on the user response
(REQUES_URI).
One example of the benefit among the others is, lets say I change my
hosting company and some how the install ruby on difference path. What I
have to do is just change
the first line from #!/bin/ruby to #!/user/bin/ruby (this is example
only!) in the index.rb

The reason I ask is I already try to use Webrick and doesn't do what I
want.
What happen to my scripts is, lets say I already use my browser to hit
http://127.0.0.1/index.rb/init/version than after that I hit
http://127.0.0.1/index.rb/bittorrents/main ,
Webrick will always give the same result as
http://127.0.0.1/index.rb/init/version

I really want to use webrick also for my RubyToday project

May be I am doing some thing wrong here. I don't know

--
Bill Guindon (aka aGorilla)

vruz wrote:

Actually, I believe in the single point of entry power.
I used it in FuseLogic(php) and QLogic (ruby). index.php or index.rb
will decide which module will be executed base on the user response
(REQUES_URI).
One example of the benefit among the others is, lets say I change my
hosting company and some how the install ruby on difference path. What I
have to do is just change
the first line from #!/bin/ruby to #!/user/bin/ruby (this is example
only!) in the index.rb
The reason I ask is I already try to use Webrick and doesn't do what I
want.
What happen to my scripts is, lets say I already use my browser to hit
http://127.0.0.1/index.rb/init/version than after that I hit
http://127.0.0.1/index.rb/bittorrents/main ,
Webrick will always give the same result as
http://127.0.0.1/index.rb/init/version

I really want to use webrick also for my RubyToday project

May be I am doing some thing wrong here. I don't know

Regards
Eko
   
Jeremy, the confusion arises because Eko is asking about a completely
different , unrelated, problem in this thread.

Eko, maybe if you post some source code to look at ?

That will make it way much easier to find what's your your problem about

cheers,
                     vruz

Ok, here is my code

···

#-----------------------------------------------------------------
#
#File Name = class.index.rb
#

class Index < HTTPServlet::AbstractServlet

    def do_GET(req,resp)
    temp = req.unparsed_uri.to_s
    temp = temp.str_ireplace('/index.rb/','')
    temp = 'fuse='+temp
    ARGV[0] = temp load('coreLoader.rb')
        resp.body = $Layout end
       def Index.get_instance config, *options
      load __FILE__
    load('coreLoader.rb') Index.new config, *options end
   end

#----------------------------------------------------------------------
#
#file name = start_webrick.rb
#

require 'webrick'

class String
  def str_replace(what,with)
    re = Regexp.new(Regexp.quote(what))
    self.gsub(re,with)
  end def str_ireplace(what,with)
    re = Regexp.new(Regexp.quote(what), Regexp::IGNORECASE)
    self.gsub(re,with)
  end
end

$Layout = ''
def puts(string = '') $Layout += "\n"+string.to_s
    super
end

include WEBrick

load('class.index.rb')

def start_webrick(config = {})
    ##config.update(:Port => 8080)
    config.update(:Port => 80)
    config.update(:DirectoryIndex => 'a.rb')
    $server = HTTPServer.new(config)
    yield server if block_given?
    ['INT','TERM'].each { |signal|
        trap(signal) {server.shutdown}
    }
    $server.mount('/index',Index) $server.start
end
   start_webrick(:DocumentRoot => File.dirname(__FILE__))

regards
Eko

Bill Guindon wrote:

···

On Mon, 7 Mar 2005 12:54:39 +0900, Eko Budi Setiyo ><contact_us@haltebis.com> wrote:

Actually, I believe in the single point of entry power.
I used it in FuseLogic(php) and QLogic (ruby). index.php or index.rb
will decide which module will be executed base on the user response
(REQUES_URI).
One example of the benefit among the others is, lets say I change my
hosting company and some how the install ruby on difference path. What I
have to do is just change
the first line from #!/bin/ruby to #!/user/bin/ruby (this is example
only!) in the index.rb

The reason I ask is I already try to use Webrick and doesn't do what I
want.
What happen to my scripts is, lets say I already use my browser to hit
http://127.0.0.1/index.rb/init/version than after that I hit
http://127.0.0.1/index.rb/bittorrents/main ,
Webrick will always give the same result as
http://127.0.0.1/index.rb/init/version

I really want to use webrick also for my RubyToday project

May be I am doing some thing wrong here. I don't know
   
What are you doing in index.rb? I'd think a simple 'include' would do
it after you parse the URI, but I could be missing something.

index.rb is the gate off all the module. inside module there are submodule or "fuse'
index.rb is some kind of the gate to "Front Controller"

regards
Eko