1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Running a web site from the NAS200 May 2009

Discussion in 'Cisco/Linksys Network Storage Devices' started by Jan Sterenborg, Sep 15, 2012.

  1. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Work with windows 7 ultimate; don’t laugh!
    An example of Jac Goudsmit some years ago, I will try to realise it.
    http://www.linksysinfo.org/index.ph...-firmware-for-nas200.28617/page-2#post-140355
    I downloaded jac4 firmware and installed it
    I changed the root password
    Then I downloaded the two programs:
    PuTTY and WinSCP
    Used the external IP address and port 22, which I first forwarded in my router
    Everything works!
    Now I made two maps on Disk1 of the nas200
    rc.d and webroot
    Then I downloaded the Photoalbum program: Web Album Generator, as Jac suggested in the example and placed the album in the map webroot
    Then I made a script with lf as Jac suggested in the example and
    Put it in the map rc.d
    Next I changed port 80 in 8080 and forwarded it to the nas200
    Then I restarted the nas200
    And approached it with the external IP address and port 8080
    What do I see next?
    I see the old startupscreen from the nas200
    Where is my album?

    Then I can understand the sentence Jac wrote in his example:
    The thttpd program on the NAS200 uses index.cgi instead of index.html as default web page..

    There's an easy workaround: just copy your index.html to index.cgi and the web page will come up just fine. And because the original index.html is also still there when you make a copy, any pages that refer to it will also still work.

    But what does he mean by: just copy your index.html to index.cgi?
    Do I replace the cgi file? Or do I add something to the cgi file?
    The questions I am stuck with are:
    do I have to make a copy of the cgi file first, so I can reconstruct the situation later?
    And what is meant by just copy?

    Thank you
     
  2. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    The sound of silence
    There is a little light... Linux shows everyting and Windows shows only what i need as a user
    So when Jac says put something on Disk1 then from a Windows perspective this is simple but from a Linux perspective I put something in the data map of disk1; quite a difference!
     
  3. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    A second problem is now when I put something with the WinSCP program on Disk1, so Linux wise, and I restart the nas200 system everything is gone!
    Jac says:
    The correct way to shut down and reboot from the command line is to run the scripts "/etc/rc.d/rc.halt" and "/etc/rc.d/rc.reboot". If you simply type "halt" and "reboot", the disks will not be synced and you may lose data.

    When I run the first script with halt in it I cannot execute the second script with the reboot in it
    or is there a way to execute both scripts at the same time?
     
  4. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Is there a possibility that in Jac5 new firmware for the nas200 there is a possibility for Windows users that we can add a script eq in the Volume_1/data map? That will give this wonderful concept, what it is in my opinion, a new boost. There is some critics on the nas200 but from a pespective of price and quality i think this is amazing and therefore I hope that Cisco will bring the nas300 or the NAS2000 like in Harry Potter the Nimbus 2000!
     
  5. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Normally when you use a non-modified version of httpd (the web server that was used in the Linksys firmware) when you open "http://address" the web server will open index.html and will serve it to the client. The modified version in the Linksys firmware (and in my firmware as well) was modified to server "index.cgi". So if you set up a web site whose default page is saved as index.html and there is no index.cgi in your web album, you will get a 404 error. But you can fix this by renaming index.html to index.cgi in the directory that httpd uses, or you can copy index.html to index.cgi.

    Hope this helps.

    Sorry for the delay, I don't monitor the Linksysinfo.org every day anymore and this question hadn't shown up in my RSS feed until now.

    ===Jac
     
  6. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    You run the /etc/rc.d/rc.halt script if you want to shut down the system.

    or:

    You run the /etc/rc.d/rc.reboot script to shut down and reboot the system.

    There is no need to run both: each has a different purpose.
    Sorry, I thought this was obvious...

    ===Jac
     
  7. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac thanks for your replys time is nothing
    we are not Linux experts thats perhaps a handicap I know something of it because all systems are the same but in detail.....
    i understand the thing of renaming the index,html file to index.cgi file
    but where do i put it in which map
    i noticed that linux shows us all the maps which is an advantage but windows shows us only what we need to know to use the system
    i nearly lost the issue
    do i put the script in the Volume_1/data map? or on the Volume_1 map? For window users the Wolume_1/data map is accessible
    thank you
    ps i understand that it is an old issue but of interest to us because we want to use the nas200 as a simple webserver sorry for all the trouble
     
  8. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    I think the word you're looking for is "folder" not "map" (Engels is moeilijk :) )

    In the Linux file system on the NAS200, partition 1 of disk 1 is at /harddisk/Volume_1/data. This folder is shared to the Windows world through the "DISK 1" share.

    The script goes into the rc.d directory at the root level of the disk; you have to create that directory first. The script can be called anything but it has to start with "rc.". For example your script can be called "/harddisk/Volume_1/data/rc.d/rc.myweb". From the Windows point of view you will see it as "\\NAS200\DISK 1\rc.d\rc.myweb". The name of the directory (rc.d) and the name of the script file (rc.myweb) must be in lower case (so no "rc.D" or "RC.MyWeb" or whatever: this won't work).

    In the original article that you linked to in the first post, I put an example script that uses the webroot directory from the hard disk's root directory: /harddisk/Volume_1/data/webroot. From Windows point of view this is \\NAS200\DISK 1\webroot.

    The above assumes that your NAS is called "NAS200" and you use it in "Separate Disks" mode. If your NAS is called something else, it changes the network path (e.g. \\NAS200 becomes \\JAC if your NAS is named "JAC"). If you use a RAID configuration, your disks may be mounted at /harddisk/Volume_3/data and in the network paths, "DISK 1" changes into "DISK".

    You'll figure it out (and you'll learn something about Linux too :) )

    ===Jac
     
  9. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac
    thanks for your reply
    this sounds clear to me I will try to realize it now with this new information
    you gave me a map and now i can put it in the right folder! :)
     
  10. Jan Sterenborg

    Jan Sterenborg Serious Server Member

  11. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac,
    Is there a script that we can put in the rc.d folder, by which we can test that when the Nas200 starts-up that the rc.d folder is really visited e.g. 5 beeps or a text on the screen “I am in the folder rc.d, have a break”. So we can determine that that piece of the procedure is working.
    Thanks
     
  12. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    script rc.000000halt in the folder rc.d

    #!/bin/bash
    read -s -n 1 -p “Press ENTER to continue…”
    echo

    no response so my conclusion is the procedure doesn't enter the rc.d folder on disk 1
     
  13. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Sorry wrong content in halt script see below
    script rc.000000halt in the folder rc.d

    #!/bin/sh
    /etc/rc.d/rc.halt
     
  14. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Looks okay to me, but I can't verify from your pictures if you wrote the script file with Linux line endings. The easiest way to make sure this works okay is to create the script files with the editor that's built in to WinSCP.

    ===Jac
     
  15. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    The easiest way to verify that a script is running or has run, is to make it echo to a log file. If you use ">" it will erase the log, and if you use ">>" it will add lines to the file. Using "2>&1" re-routes error output to the standard output device. You can open the file with WinSCP's editor to see how far your script got. For example:

    #!/bin/shecho "Hello World!" >log.txt
    echo "Starting web server" >>log.txt
    /usr/sbin/thttpd -d /harddisk/volume_1/data/webroot -r -u admin >>log.txt 2>&1
    echo "Web server running!" >>log.txt

    The log.txt file will be written in the rc.d directoy, if I'm not mistaken.

    Another good idea is to log in through SSH and run your script manually so you can see any errors as they happen. Once you're confident that your script works, you can reboot the NAS200 using etc/rc.d/rc.reboot and it will be started automatically if it's in the correct location.

    ===Jac
     
  16. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    This won't work. It just waits for a keystroke from the serial port, which you probably don't have.

    ===Jac
     
  17. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Putting a script in rc.d that halts your NAS200 is a VERY bad idea! If this would work, it would automatically shut your NAS down as soon as it starts up!

    Hopefully this is not working, otherwise you just painted yourself into a corner. You will need to delete this script!

    ===Jac
     
  18. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac
    I was lucky I didn´t realize the consequence of the haltscript! a beginners mistake... it has been a while that programming was my life.
    Thanks fot all the replys!
    did you notice the information on the website about this problem:
    http://www.devrijecultureleruimte.nl/nas200-pict.html
     
  19. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac
    I tested the script could not find an editor in WinSCP so i Used Notepad++
    and wrote the scrip to disk as a Unix script file (also presented on the above mentioned webpage)
    restarted the nas200
    but there was no log file in the rc.d folder
     
  20. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Found the editor in WinSCP
     
  21. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    #!/bin/sh echo "Hello World!" >log.txt
    echo "Starting web server" >>log.txt
    /usr/sbin/thttpd -d /harddisk/volume_1/data/webroot -r -u admin >>log.txt 2>&1
    echo "Web server running!" >>log.txt

    hello jac can you make this script downloadable so that we can be sure that it is alright?
     
  22. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac
    your script manually



    #!/bin/shecho "Hello World!" >log.txt
    echo "Starting web server" »log.txt sh: cannot create log.txt: Read-only file system
     
  23. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    manually this works:

    #!/bin/sh echo "Hello World!" >/harddisk/volume_1/data/rc.d/log.txt
    echo "Starting web server" >>/harddisk/volume_1/data/rc.d/log.txt
    /usr/sbin/thttpd -d /harddisk/volume_1/data/webroot -r -u admin >>/harddisk/volume_1/data/rc.d/log.txt 2>&1
    echo "Web server running!" >>/harddisk/volume_1/data/rc.d/log.txt


    log.txt in the rc.d folder
    with content:

    Starting web server
    Web server running!

    but when i restart the nas200
    there appears no log.txt file
     
  24. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    ps the above script was made with the editor in WinSCP
     
  25. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Oops! Somehow a line break went missing in my reply. It should be:
    Code:
    #!/bin/sh
    echo "Hello World!" >log.txt
    echo "Starting web server" >>log.txt
    /usr/sbin/thttpd -d /harddisk/volume_1/data/webroot -r -u admin >>log.txt 2>&1
    echo "Web server running!" >>log.txt
    
    See the attachment for a version with Unix line endings (courtesy of the Edit->EOL conversion feature of Notepad++)

    ===Jac
     

    Attached Files:

  26. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello World!
    Starting web server
    Web server running!
    This is working! Thank you Jac
    so Jac4 is working well!
     
  27. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Step 2
    After the nas200 starts up I expect to see the index file in the webroot folder as the startup screen, but I don't see it
    in my webroot folder two files
    index.html
    index.cgi (this file is the renaming of index.html)
    /usr/sbin/thttpd -d /harddisk/volume_1/data/webroot -r -u admin >>log.txt 2>&1
     
  28. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac
    or do I have to put the following script in the rc.d folder too?


    Code:
    #!/bin/sh
    #
    # Save this as e.g. rc.d/rc.00rctoram
    # The two zeroes in the file name are to make sure it gets done early
    #
    rm /etc/rc.d
    cp -a /etc.links/rc.d /etc
    
     
  29. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac
    is this another approach or basically the same?

    The bottom line is, you can't simply change the existing index.htm and save it in-place; you will have to follow a different tactic. Since you want to use the existing web pages and therefore the existing web server (which is heavily patched), you will probably want to do the following (replace '#' in all commands with the appropriate number for your system):


    1. Create a directory on your hard disk and copy the ENTIRE directory tree using a command prompt.
    Code:
    mkdir -p /harddisk/volume_#/data/www
    cp -a /home/httpd/html/. /harddisk/volume_#/data/www
    2. Now create a startup script that modifies the web server configuration file on-the-fly and changes the root directory of the web server:
    Code:
    #!/bin/sh
    #
    # Name this file rc.myweb and write it into a directory rc.d under the
    # root directory of the first hard disk. Note, use a Unix compatible editor
    # so the line endings are Line Feeds, not Carriage Return + Line Feeds.
    # You can also use WinSCP's built-in editor to write the file to
    # /harddisk/volume_#/data/rc.d/rc.myweb. WinSCP's editor will create the
    # line endings correctly.
    #
    sed -i 's,^dir=.*,dir=/harddisk/volume_#/data/www,g' /etc/thttpd.conf
    3. After this, whenever you reboot, the script will modify your web server's configuration file to serve web pages from your directory instead of the one in the read-only file system. You can change the pages to your heart's content because they are on your hard disk.
     
  30. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac,
    I am beginning to appreciate Linux more and more it is cryptic and compact but powerful

    /harddisk/volume_#/data/www,g'

    what means www,g'
    are that the sub-folders in the folder wwww where I kan put my web pages in?
     
  31. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Thanks for the trophy points I am very happy with those points!
    This forum gives me the feeling that we are working together.
     
  32. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac,
    i tested post 29 and my startup page looks like this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <title>Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Generator" content="Web Album Generator 1.8.2; http://www.ornj.net/" />
    <link rel="stylesheet" type="text/css" href="main.css" />
    </head>
    <body>
    <div id="header">
    <h1>Test</h1>
    </div>
    <p class="description">Various photographs that I'd like to share on the Web.</p>

    <div id="index">
    <table>
    <tr>
    <td class="thumbcell"><a href="jac.html"><img src="jac_small.jpg" title="Jac" alt="jac_small.jpg" /></a></td>
    <td class="thumbcell"><a href="_molenskinderdijk.html"><img src="_molenskinderdijk_small.jpg" title="200604_MolensKinderdijk" alt="_molenskinderdijk_small.jpg" /></a></td>
    <td class="thumbcell"></td>
    <td class="thumbcell"></td>
    </tr>
    </table>
    </div>
    <p class="footnote">Photo album created with <a href="http://www.ornj.net/">Web Album Generator</a></p>
    </body>
    </html>
     
  33. Jan Sterenborg

    Jan Sterenborg Serious Server Member

  34. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    The problem seems to me that we see the code so the code is not an executable code.
    The code in the index.cgi file has to be compiled.
    The question is now: how do we do that?
    Is there a program that can do that for us?
    Is this program in the nas200 system and if so how can we activate it?

    Another solution could be that with the suggestion of Jac in post 29 which is working we leave everyting as it is but we make e.g. new index files with an extra button: 'Enter my website'
    When we push this button the program leads us to the folder /harddisk/volume_1/data/www/website
    to page1.html an from there we can put our own website pages in the website folder.
    Can Jac alter the index.cgi and the index.htm files in the proposed way, so with this extra button? And can he put both files on this form so we can download and install them?

     
  35. Jan Sterenborg

    Jan Sterenborg Serious Server Member

  36. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Last question
    do we need a compiler that compiles a .cgi file in a executable file or does the firmware in the nas200 do that for us?. Here i meet an obstacle that i cannot master.
     
  37. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Ergo
    jac4 firmware works well
    the rc.d map is also working
    only the copying op index.html to index.cgi is not working
    what can we do about that?
    we have now explored 4 possibilities of which none of one is working
    I hope that the forum ic Jac will give us some clue
    We are about 2 mm from the desired goal
    Thank you
     
  38. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    I'm sorry I haven't been here to "hold your hand". The forum software doesn't allow me to subscribe to updates in this forum, only to single threads, and it doesn't subscribe me automatically to threads I participated in, and the RSS feed doesn't show me when a thread has updated that I've already seen. In short: I have to remember to go in here and check if something new happened...

    The web server knows how to execute .cgi files on the NAS itself, and if you put HTML in a CGI file, it will just send the HTML code to the browser so that it builds a page from it. If you know how to write CGI, you can make your own index.cgi file, but it's not too hard to modify the file from the built-in web pages. There are many tutorial websites online on how to write web pages and I think you already know how to do it. The only thing to keep in mind is that most web servers show index.html by default, and the modified web server of the NAS200 shows index.cgi by default.

    There are only 2 reasons I can think of why it's not working as expected: (1) if your CGI or HTML file has CR/LF (i.e. Windows) instead of LF (Unix) line endings, or (2) the access rights to the files are set wrong.

    Sorry, I know very little about writing web pages and my own NAS200 is no longer in use so I can't simply imitate what you did and find out why it went wrong.

    ===Jac
     
  39. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac,
    never mind but that was a beautiful song of the Beatlers 'I want to hold your hand' back in the sixties when I was in a bording school near Valkenburg in Holland, what is left of it? I mean of this cultural movement of change....
    Thanks for your suggestions it will help us further. I can understand that this project lies in the past, but since we are going back to the dark ages, the past will overtake us....
    Jac: we will work it out!
    Jan
     
  40. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Hello Jac,
    one request because...
    can you give a simple example of a .cgi file that can work?
    So that we can see what the restrictions of such a file are?
    Thanks
     
  41. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    A sad day in my life. After 38 years I have to admit to myself that I cannot solve the problem with the Nas200. All the effort all the time wasted. Although I got many suggestions it does not work. I am to believe that it is impossible to solve this problem and I want to bet 50 dollar that no one can do this. The world is a mystery richer.
     
  42. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    Header of cgi file

    _libcgi.so.0_find_val_GetArrayItem___gmon_start____Jv_RegisterClasses__fini_GetArrayFunIndex_cgi_input_parse_html_parser__GLOBAL_OFFSET_TABLE__GetKeyFunIndex_cgi_err_PRO_GetMsgByIndex_mime_header__DYNAMIC__init_libprofile.so.0_get_sw_version_get_server_name_get_html_charset_libfilesharing.so.0_GetUserInfo_GetPublicSh_DSK_DetectSysDisk_EveryoneInDiskSh_libnetwork.so_libsystem.so.0_ReadSYSInfo_libcrypt.so.1_liblog.so.0_libhd.so.0_GetDiskMode_get_free_space_PartitionInfo_ext2_llseek_libsamba.so_libschl.so.0_libflash.so.0_libdown.so.0_DownManagerEnabled_libc.so.6___errno_location_getenv_fwrite_strcat_malloc_strrchr_opendir__IO_stdin_used_access_stdout_fclose_fgetc_fopen___libc_start_main_closedir_fputc_sprintf_strstr_strcmp_free_readdir_strchr_strcpy__edata___bss_start___fini_array_end___fini_array_start___init_array_end___init_array_start_GLIBC_2.1_GLIBC_2.0
     
  43. Jan Sterenborg

    Jan Sterenborg Serious Server Member

    After darkness there was light:
    we found another way to reach our purpose and answer the original question:
    Running a web site from the NAS200?

    the answer is:

    ftp://guest@82.136.221.200:2121/peter/index.html
    this means that the guest option is turned on in the administration of the nas200
    that in the shared folders under peter the guest has reading permission
    and that port 2121 is forwarded tot the internal IP adres of the nas200
    and you are using Google Chrome.
    Its easier to marry someone.
    thank you all.
     
  44. Jan Sterenborg

    Jan Sterenborg Serious Server Member

  45. Jan Sterenborg

    Jan Sterenborg Serious Server Member

  46. Jan Sterenborg

    Jan Sterenborg Serious Server Member

Share This Page