[SOLVED]Lighttpd Web Server WAN Access interface binding bug

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2  Next
Author Message
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1856
Location: Hung Hom, Hong Kong

PostPosted: Mon Apr 24, 2023 7:11    Post subject: [SOLVED]Lighttpd Web Server WAN Access interface binding bug Reply with quote
After choosing "Enable" for "WAN Access" in Services->Services->Lighttpd Web Server,
option "server.bind" of /tmp/lighttpd.conf did NOT change from "192.168.1.1" to
"0.0.0.0"! As a result, you could not access Lighttpd from outside world when
pointing the browser to "http://my_ddns:80".

I tested this using some free web proxy servers, not just from my own LAN.

My current solution is to disable "WAN Access", then add a port-forwarding
rule from port 80 of all intefaces to port 80 of DD-WRT's LAN IP address.

Also note that you need to move "HTTP Port" away from 80 in order to test
Lighttpd because the port was completely controlled by WEBUI's httpd daemon!

The better solution is to move the port of WEBUI by setting NVRAM
variables "https_lanport" to number other than 80 and commit change.
This really fixed a lot of conflicts between Lighttpd and httpd (WebUI).

I suspected that the firewall or even the kernel deliberately give priority
to process httpd (WEBUI) over process lighttpd. I cannot prove this,
just a hunch. Or maybe the 2 processes were competing for same memory
addresses? I dunno...

Port 443 did work with Lighttpd, as long as you didn't enable WEBUI's
HTTPS access.

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw


Last edited by mwchang on Mon May 15, 2023 8:05; edited 2 times in total
Sponsor
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2967
Location: Germany

PostPosted: Mon Apr 24, 2023 9:46    Post subject: Reply with quote
Seems to be swapped.
If you disable "WAN Access" then bindhost 0.0.0.0 is used.

Port 80 is not of interest, it is not the default port that is preconfigured.
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1856
Location: Hung Hom, Hong Kong

PostPosted: Mon Apr 24, 2023 10:01    Post subject: Reply with quote
ho1Aetoo wrote:
Seems to be swapped.
If you disable "WAN Access" then bindhost 0.0.0.0 is used.

Yesterday, I did see a flash of "0.0.0.0" in /tmp/lighttpd.conf, but I was NOT so sure. Let me test again....
Quote:
Port 80 is not of interest, it is not the default port that is preconfigured.

If WEBUI httpd port stayed at 80, the HTTP port of Lighttpd Web Server would never respond, even if it's moved to ports other than 80. I might have been confused by the firewall though, because if you didn't enable Lighttpd WAN Access, its HTTP port would be closed.

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1856
Location: Hung Hom, Hong Kong

PostPosted: Mon Apr 24, 2023 10:16    Post subject: Reply with quote
mwchang wrote:
ho1Aetoo wrote:
Seems to be swapped.
If you disable "WAN Access" then bindhost 0.0.0.0 is used.

Yesterday, I did see a flash of "0.0.0.0" in /tmp/lighttpd.conf, but I was NOT so sure. Let me test again....

Oh well, need to cold boot the router to really reflect the change to WAN Access of Lighttpd Web Server! Hitting <Apply> at that page was not enough.

AND yes, when WAN Access was disabled, server.bind of Lighttpd was "0.0.0.0"!

Let me enable it and soft reboot... Hang on...

After soft reboot, when WAN Access was enabled, server.bind of Lighttpd was "192.168.1.1"!!

Hitting <Apply> of Services->Services didn't alter /tmp/lighttpd.conf immediately! Not sure whether Lighttpd was restarted regardless. And don't forget about the firewall.

Maybe I should wait for a quick fix in the next build before re-testing port 80?

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw


Last edited by mwchang on Mon Apr 24, 2023 10:29; edited 2 times in total
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2967
Location: Germany

PostPosted: Mon Apr 24, 2023 10:28    Post subject: Reply with quote
The default HTTP port for lighthttp is 8000 and not 80
Configure garbage = get garbage

You do realize that you can't run 2 webservers on the same interface and on the same port?


I have already found out the rest and forwarded it to BS.
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1856
Location: Hung Hom, Hong Kong

PostPosted: Mon Apr 24, 2023 10:34    Post subject: Reply with quote
ho1Aetoo wrote:
The default HTTP port for lighthttp is 8000 and not 80
Configure garbage = get garbage

You do realize that you can't run 2 webservers on the same interface and on the same port?

Yes.

But what if you make WEBUI (httpd) listen on HTTPS while Lighttpd on HTTP? Would WBEUI release port 80 correctly? Smile

What would happen if both WEBUI and Lighttpd use HTTPS?

Should there be Javacript error messages to reject port conflict between Lighttpd & WEBUI httpd?
Quote:
I have already found out the rest and forwarded it to BS.

Thank you!

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2967
Location: Germany

PostPosted: Mon Apr 24, 2023 10:43    Post subject: Reply with quote
everything works as long as the 2 servers do not use the same port

default:
httpd = port 80
lighthttpd = port 8000+443

or

httpd = port 443
lighthttpd = Port 80+4433

or whatever, common sense should explain it
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1856
Location: Hung Hom, Hong Kong

PostPosted: Mon Apr 24, 2023 10:47    Post subject: Reply with quote
ho1Aetoo wrote:
everything works as long as the 2 servers do not use the same port

default:
httpd = port 80
lighthttpd = port 8000+443

or

httpd = port 443
lighthttpd = Port 80+4433

or whatever, common sense should explain it

A Javascript error message would be good!

Or if it's too much work, just ignore/refuse those changes and keep the old values in the user interface, regardless of hitting <Apply>, soft reboot, or cold boot.

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2967
Location: Germany

PostPosted: Mon Apr 24, 2023 10:51    Post subject: Reply with quote
you will not have much success with this request, BS is not a friend of popups and help messages.
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1856
Location: Hung Hom, Hong Kong

PostPosted: Mon Apr 24, 2023 11:27    Post subject: Reply with quote
ho1Aetoo wrote:
you will not have much success with this request, BS is not a friend of popups and help messages.

Error messages could save developers time and reduce number of tickets and complaints from users.

Anyway, I don't run the show. The simple method is to ignore bad and/or conflicting values. Smile

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1856
Location: Hung Hom, Hong Kong

PostPosted: Mon Apr 24, 2023 13:54    Post subject: Reply with quote
ho1Aetoo wrote:
you will not have much success with this request, BS is not a friend of popups and help messages.

BTW, speaking of Javascript and WEBUI, reminded me of the_joker....

DD-WRT :: Viewing profile
https://forum.dd-wrt.com/phpBB2/profile_sec.php?mode=viewprofile&u=464210&sid=deed8d285a06c9d400686cc5782a6495

Seemed that he's stopped updating his GitHub after year 2022...

the-j0k3r · GitHub
https://github.com/the-j0k3r

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
dale_gribble39
DD-WRT Guru


Joined: 11 Jun 2022
Posts: 1927

PostPosted: Thu May 11, 2023 22:25    Post subject: Reply with quote
Going by https://github.com/mirror/dd-wrt/blob/master/src/router/services/services/lighttpd.c as well as the "configs" under https://github.com/mirror/dd-wrt/tree/master/src/router/lighttpd/, the only thing to search for is where the redirect port is hard-coded, as I can't seem to find it(yet). The ssl port is whatever you set it to in the webUI and the default listen port is 8000.

Lighttpd's SSL port

_________________
"The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost

"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio

<fact>code knows no gender</fact>

This is me, knowing I've ruffled your feathers, and not giving a ****
Some people are still hard-headed.

--------------------------------------
Mac Pro (Mid 2012) - Two 2.4GHz 6-Core Intel Xeon E5645 processors 64GB 1333MHz DDR3 ECC SDRAM OpenSUSE Leap 15.5
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1856
Location: Hung Hom, Hong Kong

PostPosted: Sat May 13, 2023 9:40    Post subject: Reply with quote
I found the problem in the source codes. It's line 131 in lighttpd.c!

https://github.com/mirror/dd-wrt/blob/2f909db661836cd8a3a0a7f90748c91e9ded8503/src/router/services/services/lighttpd.c#L128

Line 128-131:
Code:
"server.bind           = \"%s\"\n"
"server.port           = %s\n"
"server.document-root  = \"%s\"\n",
nvram_safe_get("lighttpd_sslport"), nvram_match("lighttpd_wan", "0") ? "0.0.0.0" : nvram_safe_get("lan_ipaddr"), nvram_safe_get("lighttpd_port"), nvram_safe_get("lighttpd_root"));
The focus was:
Code:
nvram_match("lighttpd_wan", "0") ? "0.0.0.0" : nvram_safe_get("lan_ipaddr")

It should have been:
Code:
nvram_match("lighttpd_wan", "1") ? "0.0.0.0" : nvram_safe_get("lan_ipaddr")

When lighttpd_wan was "1", bind all interfaces (LAN + WAN) by using "0.0.0.0". When lighttpd_wan was "0", bind only to the LAN interface with lan_ipaddr!

Lighttpd by default bind to all interfaces. There is no need add the "server.bind" clause and set it to "0.0.0.0". But this change will be more complicated than just correcting the value.

Server bindDetails - Lighttpd - lighty labs
https://redmine.lighttpd.net/projects/1/wiki/Server_bindDetails

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw


Last edited by mwchang on Sat May 13, 2023 10:05; edited 8 times in total
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1856
Location: Hung Hom, Hong Kong

PostPosted: Sat May 13, 2023 9:41    Post subject: Reply with quote
dale_gribble39 wrote:
Going by https://github.com/mirror/dd-wrt/blob/master/src/router/services/services/lighttpd.c as well as the "configs" under https://github.com/mirror/dd-wrt/tree/master/src/router/lighttpd/, the only thing to search for is where the redirect port is hard-coded, as I can't seem to find it(yet). The ssl port is whatever you set it to in the webUI and the default listen port is 8000.

Lighttpd's SSL port

Thanks! I had edited the subject of this thread to avoid confusion.

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2967
Location: Germany

PostPosted: Sat May 13, 2023 17:24    Post subject: Reply with quote
https://svn.dd-wrt.com/changeset/52514

now happy?

_________________
Quickstart guides:
use Pi-Hole as simple DNS-Server with DD-WRT
VLAN configuration via GUI - 1 CPU port
VLAN configuration via GUI - 2 CPU ports (R7800, EA8500 etc)

Routers
Marvell OCTEON TX2 - QHora-322 - OpenWrt 23.05.3 - Gateway
Qualcomm IPQ8065 - R7800 - DD-WRT - WAP
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum