Potreboval jsem, aby byl uzivatel vzdy presmerovan na http://192.168.50.1/index.html, bez ohledu na to, co tam zada. Tedy napriklad http://192.168.50.1/pokus.html a http://192.168.50.1/windows_xp.iso musi vzdy zobrazit http://192.168.50.1/index.html.
Vyresit se to da jednoduse pomoci parametru pri spusteni web serveru:
/usr/sbin/httpd -p 80 -h /www -r OpenWrt -H 192.168.50.1 -R /index.html
-H presmeruje na IP a -R presmeruje na soubor, ktery je ulozen v adresari webserveru /www.
Pokud chceme pouzit vychozi zpusob nastaveni v OpenWrt UCI, musime upravit prislusny soubor /etc/config/httpd:
12345 config httpdoption port 80option home /www<b>option host 192.168.50.1</b><b>option path /index.html</b>
S promennymi host a path ale OpenWrt nepocita, proto je jeste potreba neco pridat souboru /etc/init.d/httpd:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 #!/bin/sh /etc/rc.common# Copyright (C) 2006 OpenWrt.orgSTART=50HTTPD_BIN="/usr/sbin/httpd"system_config() {<span style="white-space:pre" class="Apple-tab-span"> </span>local cfg="$1"<span style="white-space:pre" class="Apple-tab-span"> </span>config_get hostname "$cfg" hostname}httpd_config() {<span style="white-space:pre" class="Apple-tab-span"> </span>local cfg="$1"<span style="white-space:pre" class="Apple-tab-span"> </span>local c_file port realm home args<span style="white-space:pre" class="Apple-tab-span"> </span>config_get c_file "$cfg" c_file<span style="white-space:pre" class="Apple-tab-span"> </span>[ -n "$c_file" -a -f "$c_file" ] && append args "-c \"$c_file\""<span style="white-space:pre" class="Apple-tab-span"> </span>config_get port "$cfg" port<span style="white-space:pre" class="Apple-tab-span"> </span>append args "-p ${port:-80}"<span style="white-space:pre" class="Apple-tab-span"> </span>config_get home "$cfg" home<span style="white-space:pre" class="Apple-tab-span"> </span>home="${home:-/www}"<span style="white-space:pre" class="Apple-tab-span"> </span>[ -d "$home" ] || return 1<span style="white-space:pre" class="Apple-tab-span"> </span>append args "-h \"$home\""<span style="white-space:pre" class="Apple-tab-span"> </span>config_get realm "$cfg" realm<span style="white-space:pre" class="Apple-tab-span"> </span>realm="${realm:-$hostname}"<span style="white-space:pre" class="Apple-tab-span"> </span>append args "-r \"$realm\""<b>############################## <br /> config_get path "$cfg" path <br /> path="${path:-$path}" <br /> append args "-R \"$path\"" <br /> config_get host "$cfg" host <br /> host="${host:-$host}" <br /> append args "-H \"$host\"" <br /> ############################## <br /> </b>eval "$HTTPD_BIN $args"}start() {<span style="white-space:pre" class="Apple-tab-span"> </span>[ -x "$HTTPD_BIN" ] || return 1unset hostname<span style="white-space:pre" class="Apple-tab-span"> </span>config_load system<span style="white-space:pre" class="Apple-tab-span"> </span>config_foreach system_config system<span style="white-space:pre" class="Apple-tab-span"> </span>hostname="${hostname:-OpenWrt}"<span style="white-space:pre" class="Apple-tab-span"> </span>unset args<span style="white-space:pre" class="Apple-tab-span"> </span>config_load httpd<span style="white-space:pre" class="Apple-tab-span"> </span>[ "$?" != "0" ] && {<span style="white-space:pre" class="Apple-tab-span"> </span>uci_set_default httpd <<EOFconfig 'httpd'<span style="white-space:pre" class="Apple-tab-span"> </span>option 'port' '80'<span style="white-space:pre" class="Apple-tab-span"> </span>option 'home' '/www'EOF<span style="white-space:pre" class="Apple-tab-span"> </span>config_load httpd<span style="white-space:pre" class="Apple-tab-span"> </span>}<span style="white-space:pre" class="Apple-tab-span"> </span>config_foreach httpd_config httpd}stop() {<span style="white-space:pre" class="Apple-tab-span"> </span>killall httpd}
Staci pridat vyznacenou cast. Po rebootu by to uz melo fungovat. Dalsim resenim by mohlo byt pouziti jineho weboveho serveru.
Dalsi clanky o OpenWrt.