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

How to expand webserver capabilities!

Discussion in 'Tomato Firmware' started by psychowood, Mar 17, 2007.

  1. psychowood

    psychowood LI Guru Member

    Hi all,
    I was curious about this thing, so sent a mail to Jon. I've just got a reply from him, he said that the Tomato webserver can already serve files not in /www :eek:

    Basically, just create the dir /var/wwwext (or /tmp/var/wwwext) then put the files there (it's RamFS, so avoid using big files :rolleyes: ) and you can access them just opening http://router/ext/filename

    Jon also said that only a few certain extensions are supported - txt, htm, js, gif, jpg, png, css. Use .bin if you want to trigger a "save as" download. I renamed a txt file to .asp and it opened it, so possibly can support dynamic pages too. :clap2:

    You can also use symbolic links to files that are outside wwwext (tried personally with a file in jffs), so it should work even with cifs mount (not wasting ram for files :biggrin: ). Not sure if you can symlink directly wwwext, tho.

    Hope this can be useful to someone, I'm happy to have something more I can mess up :jester:
     
  2. mikester

    mikester Network Guru Member

    Sweet - will try it
     
  3. psychowood

    psychowood LI Guru Member

    Show NVRam content

    1st try.
    Rename the attachment from .asp.txt to .asp and put it in /var/wwwext, then open the url http://router/ext/nvramshow.asp to see a page that shows the contents of your nvram :)

    A screenshot:

    [​IMG]

    It reads Tomato gui style, too :biggrin:
     

    Attached Files:

  4. digitalgeek

    digitalgeek Network Guru Member

    Sweet...!(thx psycho for the nvram show file) as my linux/unix is a little rusty can somebody assist me with the symbolic link?
     
  5. psychowood

    psychowood LI Guru Member

    Just "ln -s TARGET LINKNAME" (without double quotes, of course :)) so if you want to link, for example, the file page.asp in /cifs1, just type

    ln -s /cifs1/page.asp /var/wwwext/page.asp

    Btw, no need to thx for that file, it's a simple experiment, I'm just glad if someone find it useful ^^

    If someone has proposal or requests, just ask :D
     
  6. bokh

    bokh Network Guru Member

    Good idea! But not really working here... All I get is a white page with this:

    Code:
    Tomato
         Version 1.06.0981
     WRT54GL
        NVRam contents
    The NVRAM does show up in the HTML-source however.
    And how does the code "know" where to find the CSS- and JS-code in /www/ ?
    Any ideas?
     
  7. Hypernova

    Hypernova LI Guru Member

    Works for me, I have the script on a lan share and points the wwwext folder to it as symbolic. i.e. typing router\ext\xxx auto points to cifs1\sbin\xxx.

    There seems to be a file size limit. I tried transmitting a 100MB rmvb by renaming it into XXX.rmvb.bin but the dl ends in a 0 byte file. Guess that means you can't use it as a simple http file share server.
     
  8. psychowood

    psychowood LI Guru Member

    Uhm, did you rename the file to .asp? That seems to be the same output I was getting when trying to run "code" in .txt pages..

    I simply use the html base tag to tell the browser to take nvram.lan_ipaddr as root for the links.

    In detail
    Code:
    <script type="text/javascript">document.write('<base href="http://'+nvram.lan_ipaddr+'/">')</script>
    
    Btw, you also have the same router and firmware version of mine..
    Oh, and I'm using a custom css template.
     
  9. bokh

    bokh Network Guru Member

    - yes, I DID rename the file to .ASP
    - yes, I use a custom css too
    - symlinking the file from CIFS into /var/wwwext/ didn't work either

    Pitty... I'm pretty much puzzled! :mad:
     
  10. digitalgeek

    digitalgeek Network Guru Member

    I followed the instructions above for the symbolic link and had no problems...

    ln -s /cifs1/nvramshow.asp /var/wwwext/nvramshow.asp

    I have even set symbolic link to the custom.css file:
    ln -s /cifs1/custom.css /var/wwwext/custom.css

    the symbolic link solved the problem of the cp of the .css file before the fileshare (cifs1) was mounted.
     
  11. digitalgeek

    digitalgeek Network Guru Member

    I followed the instructions above for the symbolic link and had no problems...

    ln -s /cifs1/nvramshow.asp /var/wwwext/nvramshow.asp

    I have even set symbolic link to the custom.css file:
    ln -s /cifs1/custom.css /var/wwwext/custom.css

    the symbolic link solved the problem of the cp of the .css file before the fileshare (cifs1) was mounted.


    I have noticed that if I navigate to: //devicename/ext/nvramshow.asp and then click on status -> overview the router will change the url to //192.168.1.1/ ????
     
  12. psychowood

    psychowood LI Guru Member

    I'm puzzled as much as you.. really don't know why it isn't working :frown:
    Another stupid question: are you using http access, and not https, right?

    Yep, that's correct. It is because the script has links dinamically generated from the router ip got from nvram, and since I can't reach the router via its hostname (don't know why, tho :mad: ) I didn't notice that "problem".
    If you want, you can change, in the asp file, lan_ipaddr in router_name, in line 18. Just tested, works flawlessly :)
     
  13. bokh

    bokh Network Guru Member

    Nope, I'm on HTTPS - can't be too careful these days.
    I'll try with HTTP too, or edit your script: %s/http/https/g :biggrin:

    UPDATE
    Works over HTTP indeed (set access to HTTP & HTTPS so I still have a choice) and using a symlink to CIFS on FreeBSD. I had to do a dos2unix-conversion of the file first though, 'cause I saved it first on my Mac and it didn't work at first...
    Thanks for the not so stupid question!
     
  14. digitalgeek

    digitalgeek Network Guru Member

    There must be away to pull this from the nvram or from the url...?
     
  15. back0rifice

    back0rifice Network Guru Member

    Hi!

    Sorry for digging out this old thread but my question is related and I haven't found any answer so far...

    What I would like to do is to host a simple tiny asp file on my router with a button that sends a WOL magic packet to a computer in my home LAN. I successfully prepared a script, put it in /www/ext and can access and execute it from a computer in the LAN.

    However, I would like to also have access to this page from the public internet. Ist there any way to achieve this...

    - ... without enabling HTTP administration (is currently turned off)
    - ... without using authentication or with credentials different from the root login

    That would be awesome...
     
  16. rhester72

    rhester72 Network Guru Member

    Not without a separate web server (Hiawatha is a good choice), a fakenet IP (alias on br0) and appropriate iptables forwarding rules (NOT from the GUI), no.

    Rodney
     
  17. back0rifice

    back0rifice Network Guru Member

    Thanks. That sounds pretty complicated though... :-/

    Do you think any other distribution would do the trick out of the box?
     
  18. rhester72

    rhester72 Network Guru Member

    DD-WRT *might* do CGI out of the box with mega, I'm not sure.

    Rodney
     
  19. josh6025

    josh6025 Networkin' Nut Member

    I have gotten this working on v1.27vpn3.6.4b664ba6. The issue was because I was using HTTPS and all that needed to be changed HTTP to HTTPS in the base href tag.
     
  20. KyleS

    KyleS Networkin' Nut Member

    While I realize this thread is pretty old... It would be fantastic to have the NVRam Display Tool added to the custom Tomato builds flying around here. It would help a lot of users who are unfamiliar with Shell to be able to debug their issues quicker, and faster.
     
  21. Toastman

    Toastman Super Moderator Staff Member Member

    Tip - We already have "download nvram dump" in the admin/debug page.
     

Share This Page