Serving an additional webpage

I am trying to set up uhttpd to serve luci on the default port 80 and a different page/set of pages on port 100.
The page uhttpd server configuration indicates that I simply have to include another config uhttpd main section in the same /etc/config/uhttpd file and uhttpd will start up a second instance but that isn't working for me / I have a problem with the syntax in the file so no other uhttpd instance starts, just one.

I have set up a /site directory, put an index.html file in there and it will display if I use a uhttpd config file which does not include any of the default text from the main section.... so I don't think that it's a permission problem.

I have also tried creating a fu.html file in the /www directory and simply accessing that by pointing my browser at /fu.html. This results in that page flashing by briefly and then being replaced by the luCi login page. Clearly there is some magic / redirect setting which I haven't found in the documentation.

I'd be happy to correct the docs, if somebody can give me a working solution.

By default /www/index.html redirects you to /cgi-bin/luci which is the default CGI gateway for LuCI.

From the page you mentioned, near the end.

Do you care to share your code for uhttpd?

cp -f -a /rom/etc/config/uhttpd /etc/config/uhttpd
mkdir -p /www/extra
uci revert uhttpd
uci -q delete uhttpd.extra
uci set uhttpd.extra=uhttpd
uci add_list uhttpd.extra.listen_http='0.0.0.0:8080'
uci add_list uhttpd.extra.listen_http='[::]:8080'
uci add_list uhttpd.extra.listen_https='0.0.0.0:8443'
uci add_list uhttpd.extra.listen_https='[::]:8443'
uci set uhttpd.extra.redirect_https='1'
uci set uhttpd.extra.home='/www/extra'
uci set uhttpd.extra.rfc1918_filter='1'
uci set uhttpd.extra.max_requests='1'
uci set uhttpd.extra.max_connections='100'
uci set uhttpd.extra.cert='/etc/uhttpd.crt'
uci set uhttpd.extra.key='/etc/uhttpd.key'
uci set uhttpd.extra.script_timeout='60'
uci set uhttpd.extra.network_timeout='30'
uci set uhttpd.extra.http_keepalive='20'
uci set uhttpd.extra.tcp_keepalive='1'
uci commit uhttpd
service uhttpd restart

netstat -l -n -p | grep -e uhttpd
curl -k -L http://localhost:8080/
3 Likes

index.html does redirect but that wouldn’t normally effect my pointing my browser at 192.168.1.130/other page.html

Thanks for the reply. I understand some of what you’re doing here, but not all. I’ll try to look up what I don’t understand and then try it.

Is there a reason that you are doing all of this from the command line with uci commands instead of editing the config file directly with vi/vim?

on my /etc/config/uhttpd file, I have added FusionPBX on port 81 and is shown below. You can certainly change the port to 100. I hope it will shed some light to you.

#
# Original section
#
config uhttpd 'main'
        list listen_http '0.0.0.0:83'
        list listen_http '[::]:83'
        option redirect_https '1'
        option home '/www'
        option rfc1918_filter '1'
        option max_requests '3'
        option max_connections '100'
        option cert '/etc/uhttpd.crt'
        option key '/etc/uhttpd.key'
        option cgi_prefix '/cgi-bin'
        option script_timeout '60'
        option network_timeout '30'
        option http_keepalive '20'
        option tcp_keepalive '1'
        option ubus_prefix '/ubus'

#
# Additional section to serve FusionPBX on port 81
#
config uhttpd 'fusionpbx'
        list listen_http '0.0.0.0:81'
        list listen_http '[::]:81'
        option redirect_https '1'
        option home '/www/fusionpbx'
        option index_page 'index.php'
        option rfc1918_filter '1'
        option max_requests '3'
        option max_connections '100'
        option cert '/etc/uhttpd.crt'
        option key '/etc/uhttpd.key'
        list interpreter '.php=/usr/bin/php-cgi'
        option script_timeout '60'
        option network_timeout '30'
        option http_keepalive '20'
        option tcp_keepalive '1'
        option realm 'GoFLEX'
        option no_symlinks '0'

You would do the same after some sysadmin experience.
In short this is a proper to utilize OpenWrt API.

1 Like

It's a lot safer to use uci commands. Less chances for mistakes and mistyping.

1 Like

Is there any chance that you probably created this other_page.html by copying and editing index.html but the old code is stuck in the browser cache?

Welcome back, @Mazilo

You may like to use the preformatted text tool for code, as it makes it easier to read and keeps the page tidy.

@Mazilo Ah. Got it.
Not being familiar with uci I didn't give the extra config uhttpd section a different name, I had it named main also.

It would be great to clarify this on the uhttpd config page and or suggest looking at the The UCI System wiki page.

I will try to edit that page to add this info.

@Hegabo :

I quadruple checked that (both the files and the cache)... those are generic troubleshooting techniques which I'm quite familiar with but thanks for the reminder.

@vgaetera :

OK, thanks. I have experience, just not much on embedded devices/ openwrt/ uci.... I graduated university with a degree in computer science in 1987 ;).

I'm always happy to use tools which make things more foolproof. Now that I've found the UCI System page I'll poke harder at it/ familiarize myself with that method. This will let me more fully de-cypher the solution that you suggested.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.