Help configuring lighttpd Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
lanznaster
Posts: 39
Joined: Thu Sep 05, 2019 10:26 am

Re: Help configuring lighttpd

Post by lanznaster »

Yes, that is working for me too.

I have several endpoints working, but only 1 that I cant get to work.

The application is code-sever, and they do not have a base url path option, that is why I'm using what MichaIng suggested in the beggining of this thread.

Code: Select all

$HTTP["url"] =~ "^/code($|/)" {
  proxy.header = (
    "map-urlpath" => (
      "/code"  => ""
    )
  )
  proxy.server = ( "" =>
    (( "host" => "192.168.1.94", "port" => 8443))
  )
}
Before using the map-urlpath condition I was not able to reach the login page. Now I can, but after the login, instead of redirecting to the next page, it stays on the login page.

And at code-server logs, I do not see an invalid login attempt, so Im guessing the login works but it seems that in the response-header the location is ./ and I think it should be /code , so I think lighttpd should re-write the response somehow.

This is a nice app by the way, is visual studio code in the browser.
User avatar
Joulinar
Posts: 2597
Joined: Sat Nov 16, 2019 12:49 am

Re: Help configuring lighttpd

Post by Joulinar »

ah ok your are now able to connect to your new system. Unfortunately I'm not a lighttpd specialist. So my support ends at this stage :(
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
lanznaster
Posts: 39
Joined: Thu Sep 05, 2019 10:26 am

Re: Help configuring lighttpd

Post by lanznaster »

On nginx, as per code-server docs should do the trick.

Code: Select all

server {
    listen 80;
    listen [::]:80;
    server_name mydomain.com;

    location / {
      proxy_pass http://localhost:8080/;
      proxy_set_header Host $host;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection upgrade;
      proxy_set_header Accept-Encoding gzip;
    }
}
I've already added the "upgrade" => "enable" condition but results are the same.

Code: Select all

$HTTP["url"] =~ "^/code($|/)" {
         proxy.header = (
   "map-urlpath" => ( "/code"  => "" ),
   "upgrade" => "enable"
  )

         proxy.server  = ( "" =>
        (( "host" => "192.168.1.94", "port" => 8443 ))
    )
}
Maybe I need to try if I can change lightpd to nginx.

Are the configuration process for both similar?
User avatar
Joulinar
Posts: 2597
Joined: Sat Nov 16, 2019 12:49 am

Re: Help configuring lighttpd

Post by Joulinar »

from my experience nginx is somehow easier to us as revers proxy. File system structure and how to activate mods is similar.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
lanznaster
Posts: 39
Joined: Thu Sep 05, 2019 10:26 am

Re: Help configuring lighttpd

Post by lanznaster »

I've manage to get it working :)

But I forgot that I have nextcloud on the original machine, so now it is not working.

Should I add this config https://github.com/MichaIng/DietPi/blob ... cloud.conf in the new machine and add the proxy_pass part? But not sure where I should put it.
User avatar
Joulinar
Posts: 2597
Joined: Sat Nov 16, 2019 12:49 am

Re: Help configuring lighttpd

Post by Joulinar »

I guess nextcloud is still running on the old system? It should be enough to add following on your Revers Proxy

Code: Select all

$HTTP["url"] =~ "^/nextcloud($|/)" {
        proxy.server  = ( "" =>
        (( "host" => "x.x.x.x", "port" => 80 ))
    )
}
BTW on which system you are doing the SSL termination? It's enough to do it on the Revers Proxy. No need to have it done on system not directly reachable from internet.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
lanznaster
Posts: 39
Joined: Thu Sep 05, 2019 10:26 am

Re: Help configuring lighttpd

Post by lanznaster »

Hi, I've changed to nginx now :)

I've added this to nginx:

Code: Select all

location /nextcloud/ {
         proxy_pass http://192.168.1.94:80;
        }
And when I open the url http://mydomain/nextcloud from home, it changes the url to http://192.168.1.94:80/nextcloud

SSL is actually on both systems, since I did not removed from old one yet.
User avatar
Joulinar
Posts: 2597
Joined: Sat Nov 16, 2019 12:49 am

Re: Help configuring lighttpd

Post by Joulinar »

for nginx it should looks like this if I'm not mistaken

Code: Select all

location /nextcloud {
		proxy_pass http://192.168.1.94:80;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
lanznaster
Posts: 39
Joined: Thu Sep 05, 2019 10:26 am

Re: Help configuring lighttpd

Post by lanznaster »

With those configs, it still change the url http://mydomain/nextcloud to http://192.168.1.94:80/nextcloud
User avatar
Joulinar
Posts: 2597
Joined: Sat Nov 16, 2019 12:49 am

Re: Help configuring lighttpd

Post by Joulinar »

Ok I got it working on a test scenario
  1. VM hosting Nginx + SSL (dietpi-letsencrypt)
  2. VM hosting Lighttpd + Nextcloud
No changes done on VM2
On VM1 I created /etc/nginx/sites-dietpi/nextcloud.conf

Code: Select all

location /nextcloud {
                rewrite ^ /nextcloud/index.php;
        }

location ~ ^/nextcloud/(index.php)? {
                proxy_pass http://192.168.0.14:80;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
Port forwarding is active from Internet towards VM1 on port 80 + 443. Nextcloud is reachable from extern as well as intern on the FQDN
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply