NetTalk Central

Author Topic: Page only in local-mode accessible  (Read 6069 times)

Bram Klootwijk

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Page only in local-mode accessible
« on: July 07, 2007, 01:57:07 PM »
Hi all,

I want a page only accessible in local -mode (localhost:nn).

It is a admin-page and i do'nt want the page to be accessable from the web, only from the localhost.

What is the command to check that i'm local?

Greetings,
Bram

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Page only in local-mode accessible
« Reply #1 on: July 08, 2007, 11:45:23 PM »
Hi Bram,

I presume this is part of a bigger site?

If this is _all_ the interface you're providing (ie if your question could be written as "how do I limit the web server to the local machine" then the answer is to go to the Advanced tab of the web-server procedure and use the option there to "Bind" it to the 127.0.0.1 IP address.

Let's say I have a machine with 2 network cards in it, then
in the same way you can "bind" the server to the LAN network card by entering the server's LAN IP address here. For example, my machine here is 192.168.2.2 - I would thus enter 192.168.2.2 in my server. Then if I'm connected to the internet via my wi-fi, no-one coming IN  on the wi-fi can see my server.

But I suspect your issue is more complicated. It sounds like you want to allow your site to be open, but limit just 1 page to the local machine.     

In this situation you need to check the "host" setting for the request.
You can do this like this...

loc:host  string(255)
  code
  loc:host = p_web._GetHeaderField ('Host:', p_web.RequestData.DataString, 1, p_web.RequestData.DataStringLen, 1, 1)

Now that's a little clumsy so for 4.28 I've added a method so you can call it like this...
loc:host  string(255)
  code
  loc:host = p_web.GetHeaderField ('Host:')

Cheers
Bruce

Bram Klootwijk

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Page only in local-mode accessible
« Reply #2 on: July 09, 2007, 11:35:40 AM »
Hi Bruce,

yes you're right. I only want 1 page to be accessible only from localhost. That is: if i enter http://www.testhost:8080/admin, i want the admin page not be accessible. If i enter http://www.localhost:8080/admin then i want the page to be available.

In this way nobody can enter the "admin" part of the site from out there and still i can have 1 app with all the pages and logic.

I'm quit busy with Nettalk Webserver and still a great fan of
this 3rdparty tool!

Cheers,
Bram