WEB server
From DD-WRT Wiki
Revision as of 20:15, 31 March 2008 (edit) Soulstace (Talk | contribs) m ← Previous diff |
Revision as of 20:29, 31 March 2008 (edit) (undo) Soulstace (Talk | contribs) m (→How to access/edit pages) Next diff → |
||
Line 107: | Line 107: | ||
=How to access/edit pages= | =How to access/edit pages= | ||
- | You can add your own pages to /tmp/www folder and then access them with http:// | + | You can add your own pages to /tmp/www folder and then access them with http://192.168.1.1/user/Yourpage.asp |
Only static html pages, but if you need dynamic pages you can use CGI scripts (sh scripts or some binary file) | Only static html pages, but if you need dynamic pages you can use CGI scripts (sh scripts or some binary file) | ||
Line 120: | Line 120: | ||
Save your script as script.cgi and | Save your script as script.cgi and | ||
chmod +x /tmp/www/cgi-bin/script.cgi | chmod +x /tmp/www/cgi-bin/script.cgi | ||
- | You can execute the page going to http:// | + | You can execute the page going to http://192.168.1.1/user/cgi-bin/script.cgi |
- | Note: In this example, we use the /tmp directory which is actually pointing to RAM. Any pages or scripts in this directory will be lost upon | + | Note: In this example, we use the /tmp directory which is actually pointing to RAM. Any pages or scripts in this directory will be lost upon router reboot and/or power loss. So use jffs2/mmc mod or back them up!<br> |
Reference: [http://www.dd-wrt.com/phpBB2/viewtopic.php?t=29673 this thread] | Reference: [http://www.dd-wrt.com/phpBB2/viewtopic.php?t=29673 this thread] | ||
[[Category:English documentation]] | [[Category:English documentation]] | ||
[[Category:Advanced tutorials]] | [[Category:Advanced tutorials]] |
Revision as of 20:29, 31 March 2008
DD-WRT runs a small httpd server used for configuring the router. This guide will show how to use it to serve you own pages to your LAN or to the world.
Please remember that opening WEB server to the world could be potential security problem.
Contents |
Assumptions
- You have telnet and SSH enabled on your router. See Telnet/SSH_and_the_Command_Line.
- You can send files via SSH to and from your desktop (e.g with WinSCP)
- You have jffs enabled and enough free space to store your files or you have working mmc mod.
- I will assume you are installing to the jffs partition. If you are not, replace jffs with mmc or some other folder
- You have the "Enable Info Site" enabled (Administration -> Management -> WEB Access)
- Optional: you have the "Wireless GUI Access" enabled (Wireless -> Advanced Settings)
- You MUST name your index file Info.htm (note upper case "I", thus "Info.htm" and NOT "info.htm")
How will this work?
- We will move the router's web admin to port 81
- We will start your WEB server at port 80
- Optional: we will open port 80 to the world
Procedure
1) Copy your files to the router, i.e. to the /jffs folder
2) Open web admin Administration -> Diagnostics, press "Run"
3) Enter these lines to the Commands field:
killall httpd cd /www httpd -p 81 -h /www cd /jffs httpd -h /jffs
4) Press "Save Startup", the router will reboot or reboot it manually.
Optional: open to the world
1) Open web admin Administration -> Diagnostics, press "Run"
2) Enter this line to the Commands field:
/usr/sbin/iptables -I INPUT 1 -p tcp --dport 80 -j logaccept
3) Press "Save Firewall", the router will reboot or reboot it manually.
Congratulations!!!, you have your own web server running.
Please remember your router's config pages are now at 192.168.1.1:81
How to cancel this?
Telnet to the router and type:
nvram set rc_startup="" nvram set rc_firewall="" nvram commit reboot
WEB server with v24 RC5
DD-WRT runs a small httpd server used for configuring the router. This guide will show how to use it to serve you own pages to your LAN or to the world.
Please remember that opening WEB server to the world could be potential security problem.
Assumptions
- You have telnet and SSH enabled on your router. See Telnet/SSH_and_the_Command_Line.
- You can send files via SSH to and from your router (e.g with WinSCP)
- You have jffs enabled and enough free space to store your files or you have working mmc mod.
- I will assume you are installing to the jffs partition. If you are not, replace jffs with mmc or some other folder.
- Optional: you have the "Wireless GUI Access" enabled (Wireless -> Advanced Settings)
- You MUST name your index file index.htm (note: all lower case letters)
How will this work?
- We will move the router's web admin to port 81
- We will start your WEB server on port 80
- Optional: we will open port 80 to the world
Procedure
1) Copy your files to the router, i.e. to the /jffs folder
2) Open web admin Administration -> Diagnostics, press "Run"
3) Enter these lines to the Commands field:
killall httpd httpd -p 81 -h /www httpd -h /jffs
4) Press "Save Startup", the router will reboot or reboot it manually.
Optional: open to the world
1) Open web admin Administration -> Diagnostics, press "Run"
2) Enter this line to the Commands field:
/usr/sbin/iptables -I INPUT 1 -p tcp --dport 80 -j logaccept
3) Press "Save Firewall", the router will reboot or reboot it manually.
Congratulations!!!, you have your own web server running.
Please remember your router's config pages are now at 192.168.1.1:81
How to cancel this?
Telnet to the router and type:
nvram set rc_startup="" nvram set rc_firewall="" nvram commit reboot
How to access/edit pages
You can add your own pages to /tmp/www folder and then access them with http://192.168.1.1/user/Yourpage.asp
Only static html pages, but if you need dynamic pages you can use CGI scripts (sh scripts or some binary file)
Create the directory /tmp/www/cgi-bin
Then create a script like:
#!/bin/sh echo "<html><body>hello world</body></html>"
Save your script as script.cgi and
chmod +x /tmp/www/cgi-bin/script.cgi
You can execute the page going to http://192.168.1.1/user/cgi-bin/script.cgi
Note: In this example, we use the /tmp directory which is actually pointing to RAM. Any pages or scripts in this directory will be lost upon router reboot and/or power loss. So use jffs2/mmc mod or back them up!
Reference: this thread