Proxy subfolders using Lighttpd mod_proxy

I am having problems getting mod_proxy to properly direct traffic to another web server running on the same computer for a predefined subfolder. Ideally, domain.com/docs should forward 127.0.0.1βˆ—000, and all other traffic should remain on domain.com. Rewrite rules here for installing wordpress, which runs on domain.com:

$HTTP["host"] =~ "(^|\.)domain\.com" { $HTTP["url"] =~ "^/docs" { proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => 3000 ))) } $HTTP["url"] !~ "^/docs/(.*)" { url.rewrite = ( "^/(.*)\.(.+)$" => "$0", "^/wp/(.*)$" => "$0", "^/(.+)/?$" => "/index.php/$1" ) server.document-root = "/mnt/webroot/html" } } 

I fought off this a bit, so any suggestions are welcome.

+4
source share
1 answer

In the end, I realized the problem that made it not work as I expected.

How lighttpd rewrites mod, it evaluates all url.rewrite commands before it evaluates its $ HTTP ["url"] conditional expressions, which means that any url.rewrite commands placed in $ HTTP ["url"] conditional will have no effect.

I was not able to find a good solution for the implementation that I was looking for with this restriction, and instead ended up moving the rewriting part downstream to another server (node ​​in this case), which I proxied traffic to.

This is freely stated in the lighttpd ModRewrite file with this line:

 NOTE: url rewriting does not work within a $HTTP["url"] conditional. 
+2
source

Source: https://habr.com/ru/post/1434750/


All Articles