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:
config httpd option port 80 option home /www option host 192.168.50.1 option path /index.html
S promennymi host a path ale OpenWrt nepocita, proto je jeste potreba neco pridat souboru /etc/init.d/httpd:
#!/bin/sh /etc/rc.common # Copyright (C) 2006 OpenWrt.org START=50 HTTPD_BIN="/usr/sbin/httpd" system_config() { local cfg="$1" config_get hostname "$cfg" hostname } httpd_config() { local cfg="$1" local c_file port realm home args config_get c_file "$cfg" c_file [ -n "$c_file" -a -f "$c_file" ] && append args "-c \"$c_file\"" config_get port "$cfg" port append args "-p ${port:-80}" config_get home "$cfg" home home="${home:-/www}" [ -d "$home" ] || return 1 append args "-h \"$home\"" config_get realm "$cfg" realm realm="${realm:-$hostname}" append args "-r \"$realm\"" ##############################
config_get path "$cfg" path
path="${path:-$path}"
append args "-R \"$path\""
config_get host "$cfg" host
host="${host:-$host}"
append args "-H \"$host\""
##############################
eval "$HTTPD_BIN $args" } start() { [ -x "$HTTPD_BIN" ] || return 1 unset hostname config_load system config_foreach system_config system hostname="${hostname:-OpenWrt}" unset args config_load httpd [ "$?" != "0" ] && { uci_set_default httpd <<EOF config 'httpd' option 'port' '80' option 'home' '/www' EOF config_load httpd } config_foreach httpd_config httpd } stop() { 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.