Cache Web Apps and Local Web Server

Primary tabs

CSP, HTML, Caché

I'm playing with Cache web apps (CSP pages) and local dev . . .

My understanding is that when you run Cache, it spins up a very lightweight Apache web server with the web root C:\InterSystems\Cache\CSP (or where your CSP folder happens to be).  I can successfully place a index.html file with a simple header element in any one of the sub directories in \CSP (e.g. samples, sys, user) and it will successfully be served on, for example, http://localhost:57772/CSP/samples/index.html.

However, if I put the index.html at C:\InterSystems\Cache\CSP\index.html or if I create a new folder and place it there (I tried C:\InterSystems\Cache\CSP\www\index.htm), I get a 404 not found error.  Note, that I created the www directory, it didn't already exist.  Nothing in the developer console on the browser seems to show any issue and I did check the httpd config file and it seems my web root is C:\InterSystems\Cache\CSP.  

So in a nutshell my config looks like this:

### Section 1: Global Environment
ServerRoot "C:/InterSystems/Cache/httpd"
ServerName localhost
DocumentRoot "C:/InterSystems/Cache/CSP"
Alias /csp/ "C:/InterSystems/Cache/CSP"
LoadModule cspsys_module_sa "C:/InterSystems/Cache/CSP/bin/CSPa24Sys.dll"
LoadModule csp_module_sa "C:/InterSystems/Cache/CSP/bin/CSPa24.dll"
<Location />
    CSP On
    SetHandler csp-handler-sa
</Location>

And I can only put HTML or CSP files in one of the existing sub directories of C:/InterSystems/Cache/CSP for them to be served successfully when requesting from localhost:57772.  If I place a HTML or CSP at the top level, or a new directory I get 404.  

Do you know what the issue could be that I can't create new folders in my web root or place files at the top level of the web root?

  • 0
  • 0
  • 67
  • 3
  • 2

Answers

You need to create a Web Application pointing to the directory you want to serve. Here's how.

By default "root" directory (C:/InterSystems/Cache/CSP/ in your case) is not served, rather each folder there is a separate Web Application.

Mike - I think the issue is that Apache is working in conjunction with Web Applications defined in Caché, and it hands off requests to the Web Applications (e.g. /csp/samples), which then serve out the files (this is configurable btw for static files).  This is why you can put something in /csp/samples or another existing web application and it works.  The issue is that in putting something at \Cache\CSP\index.csp, there is no Web Application with a root of \Cache\CSP\, and so there is no Web Application to route the request to, and thus the 404 error.  You could create a new Web Application in Caché that points to \Cache\CSP\ but that would be a bit of a security issue because people could navigate to files in other web applications from there and potentially get to things they should not.

Why do you want to put something at the top level rather than in the root for a Web Application in Caché?

Thanks, Benjamin.

I didn't realize that an application had to be created.  I have it working now. 

The link Eduard provided was helpful.

Thank you both!

Comments

Hi Mike, 

While I'm not total familiar with the syntax for your ~/.{{tcsh,bash}rc|profile|...} it seems to me that the end should be:

<Location>CSP On  SetHandler csp-handler-sa</Location>

as opposed to: <Location />CSP On  SetHandler csp-handler-sa</Location>

Minor I know, and if it html syntax likely doesn't matter at all.  Still if it is in fact a {u,li}nix resource file, syntax would be important.

Chris