Loading ...
Sorry, an error occurred while loading the content.

14788Re: running scripts from html pages served by thttpd (UNSLUNG 6.8)

Expand Messages
  • Fernando Carolo
    Aug 24, 2006
    • 0 Attachment
      Hi Rob,

      --- In nslu2-linux@yahoogroups.com, "Rob Conway" <rjconway@...> wrote:
      >
      > Hi fernando,
      > I got my script to run with your assistance, however a little strange.
      >
      > II have changed through the linksys interface the admin port number
      to 8081. My web server thttpd using port 80. I think cgi scripts
      need to us port 8081

      There is no special requirement for cgi scripts that they must (or
      even should) be run from a web server on a port number other than 80,
      but this won't hurt either.

      > So from my html page (hosted by thttpd) I have created a link to
      http://xxx.xxx.x.xx:8081/hope1.cgi I can then run this file. I think
      if its the ./management directory it has the linksys password
      implemeneted somehow, so moving it to /home/httpd/html works ok.

      Yes, the /Management directory has access control. You can do a "ls
      -a" inside it and you will see a .htpasswd file, meaning it can only
      be accessed by users listed in that file. If you want to be able to
      run your scripts without authenticating as admin, you can keep them in
      the top directory, or even create your own directory inside
      /home/httpd/html and place your scripts there.

      > Now my problem..My script runs does its script stuff and I want to
      return to my original webpage from which it was called.
      > Reading cgi I think I use the Location:webpage.html to simply
      specifiy the web page to call up and it works whilst the webpage is on
      port 8081
      >
      > As my site is using port 80 the cgi always seems to append my
      location with http://xxx.xxx.x.xx:8081/ I'm not sure what variables
      hold the original site adress which called the script. I've tried to
      reset the path_info variable.

      Every time you make an HTTP request to a server it must answer with a
      status code. When you add a "Location:" header, the server generates a
      302 status code, which means to the browser that it must fetch another
      document on another URL. Technically, this header must include a full,
      absolute URL starting with "http://", but most browsers will handle a
      relative URL and interpret it according to the original document being
      requested. In other words, the browser will look for the page
      mentioned in the Location: header in the same server. In HTTP terms, a
      server listening on a different port in the same machine is considered
      a different server, as if it were located on a different host.

      An example: if you request your cgi script on
      "http://yourslug:80801/script.cgi" and the script echoes back a
      "Location: /webpage.html" header, the browser believes that the page
      os located on the same server, on the same port. Therefore, it will
      look for "http://yourslug:80801/webpage.html".

      You want to redirect your clients to a web page on the default server
      on port 80, then your Location must point explicity to that server
      using an absolute URL. In the example, you should use "Location:
      http://yourslug/webpage.html", or "Location:
      http://${SERVER_NAME}/webpage.html" if it is a shell script.

      Regards,

      Fernando
    • Show all 6 messages in this topic