Hi Alex, Sam,
Thank you for your input.
> If your vendor documentation uses relative links, it should work as is.
i don't think so due to the additional URL path "/vendor/FOO" introduced at
the proxy as in:
https://proxyHostFQDN:proxyPort/vendor/FOO
When the routing proxy passes the usual "req.url" to the target, the prefix
"/vendor/FOO" is present.
> 1. Use subdomains, as Alex proposed
Yes, this will be a clean (thus preferred) solution. However, due to
Big-IP failover and load-balancing, the group in charge of that dictates
the URL be in the format of
https://proxyHostFQDN:proxyPort/vendor/FOO
and that is out of my control, :-(
i ended up resorting to a quick and hackish workaround: the original
document root is at the file system path:
/path/to/vendor/FOO/doc/root/...
i introduced 2 more directories in the middle as in:
/path/to/vendor/FOO/doc/root/vendor/FOO/...
When the proxy server passes on the req.url, "/vendor/FOO", it gets
absorbed by the target static file server and it has worked nicely since.
Effectively i pushed the real content 2 levels down in the file system
hierarchy. It appears that all vendor documentations use relative links
so the scheme works without a hitch. i also tested the same "hack" on
the documentations for ElasticSearch_head and Kibana (both for
ElasticSearch cluster) and it also works smoothly.
Thanks again.
On Fri, Feb 7, 2014 at 9:23 AM, Sam IT <[email protected]> wrote:
> Here are some options, sorted by, in my opinion, the more viable and easy
> solutions first:
>
> 1. Use subdomains, as Alex proposed
> No modification to the source files, which means it could be easily
> updated when you vendor updates it.
>
> 2. Add an HTML "base"
> element<https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base>to the
> "head" element of all HTML files
> You'll need to apply this method to all HTML files, you can create a
> simple middleware to get the job done.
>
> 3. Re-write all URLs
> If all urls are not relative and start with a known string, you can simply
> create a *middleware* to rewrite the prefix of those URLs.
> It does mean you may have to apply such a middleware to not only the HTML
> files, but to CSS, JS and other assets. (probably all non-binary files.)
>
> Finally, if you're going to create a middleware to accomplish #2 or #3,
> you'll need to create a Transform
> stream<http://nodejs.org/api/stream.html#stream_class_stream_transform> and
> use either string replacement or a DOM/HTML/XML parser to manipulate the
> content.
>
> Some packages I use that could be helpful to you:
> * Stream helpers: through <https://npmjs.org/package/through> or
> through2<https://npmjs.org/package/through2> are
> very simple and useful
> * HTML/DOM helper: cheerio <https://npmjs.org/package/cheerio> is very
> simple and useful as well. If you know jQuery, you'll be all set :-)
>
>
>
> On Fri, Feb 7, 2014 at 12:38 AM, Alex Kocharin <[email protected]> wrote:
>
>>
>> If your vendor documentation uses relative links, it should work as is.
>> But I guess it's not the case.
>>
>> I'd suggest to place it on a subdomain instead.
>>
>>
>> 07.02.2014, 09:24, "ming" <[email protected]>:
>>
>> Hi,
>> A few days back we received vendor FOO's documentation in electronic
>> format and we put the document root at
>> /path/to/vendor/FOO/doc/root
>>
>> With node-static and the usual:
>> var static = require('node-static');
>> var file = new static.Server('/path/to/vendor/FOO/doc/root');
>> ...
>> we quickly managed to serve the documentation up via node-static in no
>> time.
>>
>> i've also been running a reverse proxy with http-proxy which requires
>> client-side X.509 authentication. Now i'm asked to explore the
>> possibility to serve the vendor documentation through my reverse proxy and
>> the URL proposed to arrive at the document root of FOO is something like:
>> https://proxyHost:proxyPort/vendor/FOO
>>
>> With node-static and node-proxy in the picture, i can't think of an easy
>> way to achieve that unless i add the path prefix "/vendor/FOO" to all the
>> paths in the files in
>> /path/to/vendor/FOO/doc/root
>> which is quite traumatic. Is there a better (hopefully much better) and
>> less fragile way to achieve that?
>>
>> Thanks.
>>
>>
>> --
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>> --
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "nodejs" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/nodejs/2sLl4_7xahs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.