Hi,
I am trying, without success, settting up lighttpd to reverse proxy code-server app (https://github.com/cdr/code-server). I known this app is not part of dietpi, but someone might known how to do it.
I use lighttpd to reverseproxy some apps, and this one is the only one that I’m facing problems.
All apps were installed via docker.
On my lighttpd.conf, i add the following to reverseproxy an app:
$HTTP[“url”] =~ “^/sonarr($|/)” {
proxy.server = ( “” =>
(( “host” => “192.168.1.94”, “port” => 8989 ))
)
}
And its been working great, but I’m not sure what I’m missing.
I’ve searched about this, and tehy remove the option to use a base path, and that the the reverseproxy should rewrite requests.
https://github.com/cdr/code-server/discussions/1739
Does anyone known how to do this in lighttpd ?
Please try to add the proxy.header option: https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModProxy
$HTTP["url"] =~ "^/sonarr($|/)" {
proxy.header = (
"map-urlpath" => (
"/sonarr" => ""
)
)
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 8989 ))
)
}
Sorry fo the late response. I’ve tried like that and no luck
Sonarr service works, I’m having problems with this (code-server).
$HTTP["url"] =~ "^/code($|/)" {
proxy.header = (
"map-urlpath" => ( "/code" => "" )
)
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 8443 ))
)
}
The strange part is that it seens to get there, but insted of going to the login page, it says:
“401
Unauthorized”
I’ll have a look at this documentation that you linked. Will let you know how it goes.
found this at the lighttpd error log (/var/log/lighttpd/error.log):
2020-11-09 21:47:26: (server.c.1295) WARNING: unknown config-key: proxy.header (ignored)
Also just notice:
proxy.header: options to perform simple remapping of host and URL paths in proxied HTTP headers (since 1.4.46)
My version is:
root@DietPi:~# lighttpd -v
lighttpd/1.4.45 (/ssl) - a light and fast webserver
Build-Date: Jan 14 2017 21:07:19
Can I just update lighttpd?
what Debian version you are running? pls check.
echo $G_DISTRO_NAME
I hope it’s not Stretch as you need Buster to be able to upgrade lighttpd
https://packages.debian.org/de/lighttpd
Thanks for the info, I have a spare raspberrypi, if I install a new dietpi image, will it install Buster?
yes of course, Buster is the default since more than a year now 
Is there a way to just install lighttpd?
Lighttpd can be installed using dietpi-software. Software ID 84
[*] 84 Lighttpd: webserver
That was my bad, since lighttpd is the selected choice as webserver, I tought it was only installed once something that need a webserver was installed.
I’m not sure what am I doing worg now, after the fresh install on this RP3, I’ve copied the lighttpd.conf settings, only adding configurations. Like adding the the mod_proxy in the server.modules , and the endpoint settings after all default cofiguration, like the example I gave in the first post.
After that I’ve changed the port fowarding on my router to this new install.
When I try to open one of those I get ERR_CONNECTION_REFUSED
Is there something that I’m not doing?
EDIT: I also did
service lighttpd force-reload
after the changes
Here is my lighttpd.conf
lighttpd.txt (3.37 KB)
Hi,
usually there is no need to change default configuration. Just simply activate the mod by creating a symlink from
/etc/lighttpd/conf-available/10-proxy.conf
to
/etc/lighttpd/conf-enabled/10-proxy.conf
That’s how all other models and configs are activated on DietPi
root@DietPi4:~# ls -ls /etc/lighttpd/conf-enabled
total 0
0 lrwxrwxrwx 1 root root 33 Jan 18 2020 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf
0 lrwxrwxrwx 1 root root 37 Jan 18 2020 15-fastcgi-php.conf -> ../conf-available/15-fastcgi-php.conf
0 lrwxrwxrwx 1 root root 58 May 19 11:08 99-dietpi-pihole-block_public_admin.conf -> ../conf-available/99-dietpi-pihole-block_public_admin.conf
0 lrwxrwxrwx 1 root root 39 Jan 18 2020 99-dietpi-pihole.conf -> ../conf-available/99-dietpi-pihole.conf
0 lrwxrwxrwx 1 root root 38 Jan 18 2020 99-unconfigured.conf -> ../conf-available/99-unconfigured.conf
root@DietPi4:~#
10-proxy.conf contains some examples alredy
Hi,
Thanks for the info, but the results are the same
# /usr/share/doc/lighttpd/proxy.txt
server.modules += ( "mod_proxy" )
## Balance algorithm, possible values are: "hash", "round-robin" or "fair" (default)
# proxy.balance = "hash"
## Redirect all queries to files ending with ".php" to 192.168.0.101:80
#proxy.server = ( ".php" =>
# (
# ( "host" => "192.168.0.101",
# "port" => 80
# )
# )
# )
## Redirect all connections on www.example.com to 10.0.0.1{0,1,2,3}
#$HTTP["host"] == "www.example.com" {
# proxy.balance = "hash"
# proxy.server = ( "" => ( ( "host" => "10.0.0.10" ),
# ( "host" => "10.0.0.11" ),
# ( "host" => "10.0.0.12" ),
# ( "host" => "10.0.0.13" ) ) )
#}
$HTTP["url"] =~ "^/sonarr($|/)" {
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 8989 ))
)
}
$HTTP["url"] =~ "^/radarr($|/)" {
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 7878 ))
)
}
$HTTP["url"] =~ "^/bazarr($|/)" {
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 6767 ))
)
}
$HTTP["url"] =~ "^/jackett($|/)" {
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 9117 ))
)
}
$HTTP["url"] =~ "^/ombi($|/)" {
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 3579 ))
)
}
$HTTP["url"] =~ "^/tautulli($|/)" {
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 8181 ))
)
}
$HTTP["url"] =~ "^/code($|/)" {
proxy.header = (
"map-urlpath" => ( "/code" => "" )
)
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 8443 ))
)
}
$HTTP["url"] =~ "^/lidarr($|/)" {
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 8686 ))
)
}
$HTTP["url"] =~ "^/files($|/)" {
proxy.server = ( "" =>
(( "host" => "192.168.1.94", "port" => 8069 ))
)
}
And the symlink:
root@DietPi:/var/log/lighttpd# ls -ls /etc/lighttpd/conf-enabled
total 0
0 lrwxrwxrwx 1 root root 33 Nov 16 18:58 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf
0 lrwxrwxrwx 1 root root 42 Nov 17 12:27 10-proxy.conf -> /etc/lighttpd/conf-available/10-proxy.conf
0 lrwxrwxrwx 1 root root 37 Nov 16 18:58 15-fastcgi-php.conf -> ../conf-available/15-fastcgi-php.conf
0 lrwxrwxrwx 1 root root 38 Nov 16 18:53 99-unconfigured.conf -> ../conf-available/99-unconfigured.conf
Still have the “ERR_CONNECTION_REFUSED” error when triying to open in a browser.
Am I missing something?
ok i did a test on my RPi3B+ with lighttpd, sonarr and radarr. Basically I used your configuration and it’s working fine
I did a fresh installation without any configuration changes.
- activated 10-proxy.conf
root@DietPi3:/etc/lighttpd/conf-enabled# ls -la
total 8
drwxr-xr-x 2 root root 4096 Nov 17 15:47 .
drwxr-xr-x 4 root root 4096 Nov 17 14:07 ..
lrwxrwxrwx 1 root root 33 Nov 17 14:07 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf
lrwxrwxrwx 1 root root 31 Nov 17 15:47 10-proxy.conf -> ../conf-available/10-proxy.conf
lrwxrwxrwx 1 root root 37 Nov 17 14:07 15-fastcgi-php.conf -> ../conf-available/15-fastcgi-php.conf
lrwxrwxrwx 1 root root 38 Nov 17 14:03 99-unconfigured.conf -> ../conf-available/99-unconfigured.conf
- configured 10-proxy.conf
# /usr/share/doc/lighttpd/proxy.txt
server.modules += ( "mod_proxy" )
## Balance algorithm, possible values are: "hash", "round-robin" or "fair" (default)
# proxy.balance = "hash"
## Redirect all queries to files ending with ".php" to 192.168.0.101:80
#proxy.server = ( ".php" =>
# (
# ( "host" => "192.168.0.101",
# "port" => 80
# )
# )
# )
## Redirect all connections on www.example.com to 10.0.0.1{0,1,2,3}
#$HTTP["host"] == "www.example.com" {
# proxy.balance = "hash"
# proxy.server = ( "" => ( ( "host" => "10.0.0.10" ),
# ( "host" => "10.0.0.11" ),
# ( "host" => "10.0.0.12" ),
# ( "host" => "10.0.0.13" ) ) )
#}
$HTTP["url"] =~ "^/sonarr($|/)" {
proxy.server = ( "" =>
(( "host" => "127.0.0.1", "port" => 8989 ))
)
}
$HTTP["url"] =~ "^/radarr($|/)" {
proxy.server = ( "" =>
(( "host" => "127.0.0.1", "port" => 7878 ))
)
}
- changed base URL in radarr and sonarr
- restarted all services
Did you changed base URL on both application GUI’s??
Below some screenshots showing the URL without port and the changed URL Base
I have it lighttpd working on the same machine with these configurations. I’ve did a fresh dietpi install on a RPI that I wasnt using, to try the new header thing, since it only works with buster.
When I changed the configs to the new installation, and change the port foward in the router to point to the new install I get the error I mentioned.
That is why I found this “issue” strange. The same configs are working on the “original”, but old
, installation.
And thanks for trying to help 
I continued playing with it and managed to get access from internet by just switching port forwarding on my router. As well HTTPS is working fine. Do you use the default lighttpd.conf still? Or did you modified anything? To exclude port fowarding, did you checked if you are able to reach lighttpd Welcome Page, by just using your URL without any /radarr or /sonarr patch?