Forum

Intercept proxied urls and serve static files

rouilj
1 May 2017, 03:09
Hello:

I am using hiawatha to proxy to an application server. For urls of
the form /demo/@@file/... I want hiawatha to serve up the files from
/var/demo/html/...

I have the following partial configuration (this server serves up
multiple apps under different urls):

UrlToolkit {
ToolKitID = demo
# redirect non-trailing / demo to demo/
# as the / is required by server.
Match ^/demo$$ Redirect /demo/
# server redirect @@file requests directory from hiawatha
Match ^/demo/\@\@file/(.*) Rewrite /static_demo/$1
}

VirtualHost {
...
# configure for roundup
UseToolkit = demo
# required for roundup. URL demo/file11/.bashrc need to be allowed
AllowDotFiles = yes
Alias /static_demo:/var/demo/html
ReverseProxy ^/demo/ 1 http://127.0.0.1:8918/demo/ 600
...

UseDirectory = ..., static_demo, ...
}

Directory { # static files for roundup demo sysadmin tracker served by hiawatha
DirectoryID = static_demo
Path = /var/demo/html
ExecuteCGI = no
FollowSymlinks = no
ShowIndex = no
Extensions = css, js
ExpirePeriod = 2 weeks, public
Extensions = jpg, ico, gif
ExpirePeriod = 2 months, public
}


I thought this works like the following:

/demo/@@file/css/sysadmin.css is requested by the client

The url toolkit rewrites this to: /static_demo/css/sysadmin.css and returns
the new url.

/static_demo/css/sysadmin.css is matched by the alias definition

The Directory entry is consulted to get settings for expires header
and cache and returns /var/demo/html/css/sysadmin.css to the user

Wigwam verifies that /demo/@@file/css/sysadmin.css:
  url: /demo/@@file/css/sysadmin.css
new: /static_demo/css/sysadmin.css

is properly rewritten.

However when I request /demo/@@file/css/sysadmin.css I get a 404 and
the back end server sees a request for: /demo/css/sysadmin.css

If I request: /static_demo/css/sysadmin.css directly I get the css file returned.

So it looks like the Rewrite is still triggering the ReverseProxy and not the Alias
but has stripped the @@file component as expected.

I have also tried using "RequestURL isfile Return" at various points in the toolkit,
but as I expected it seems to have no effect.

Any idea what I am doing wrong?

Details: hiawatha 10.5, Ubuntu 14.04

(Also is there a way to get hiawatha to gzip compress output returned from a
back end server?)

Thanks for your help.

-- rouilj
This topic has been closed.