Can Nscp-Enterprise 2.01 do internal rewrite/redirect

Can Nscp-Enterprise 2.01 do internal rewrite/redirect

Post by Jure Simsi » Fri, 24 Dec 1999 04:00:00



We have to move a site from apache environment to a new location that
runs Netscape Enterprise 2.01. The setup they have is all cgi-bin's in
/cgi-bin dir and also they don't know much what NscpEnt can/can't do. To
match their requirements I'd like to make sure if Ent 2.01 can do an
equivalent of Apache's mod_rewrite's:

RewriteRule ^/path/to/file$ /cgi-bin/foo.cgi

which means the browser still thinks it's getting content from
/path/to/file while it's actually getting a result from a cgi..Otherwise
i'll be having problems with relative links we're using..

Another thing is also if it (Ent 2.01) can run cgi's outside the
/cgi-bin dir (the guys there said it can't) and how to set up this..[*1]
If you can, can you run a cgi named foo.html as a cgi or is the
.extension the main match to determine what to do? [*2]

(In other words, can it do:
[*1]
ScriptAlias /some/where/else/ /httpd/htdocs/some/where/else/

[*2]
<Location /path/to/foo.html>
  SetHandler cgi-script
</Location>
)

Thanx for any help and if you could give me brief directives on
configuring that as I can't rely on the owners of this servers to know
how this is done..

Jure
--
Jure Simsic


 
 
 

Can Nscp-Enterprise 2.01 do internal rewrite/redirect

Post by Peter » Fri, 31 Dec 1999 04:00:00



> We have to move a site from apache environment to a new location that
> runs Netscape Enterprise 2.01.

Hopefully 2.01c or 2.01d, as 2.01 is not y2k compliant (and has been
end-of-life'd).

Quote:> The setup they have is all cgi-bin's in
> /cgi-bin dir and also they don't know much what NscpEnt can/can't do. To
> match their requirements I'd like to make sure if Ent 2.01 can do an
> equivalent of Apache's mod_rewrite's:

> RewriteRule ^/path/to/file$ /cgi-bin/foo.cgi

> which means the browser still thinks it's getting content from
> /path/to/file while it's actually getting a result from a cgi..Otherwise
> i'll be having problems with relative links we're using..

Yes. You may need to write an NSAPI to do this; essentially the NSAPI
changes a request parameter so that the server then acts like the client
requested a different URL (though the way we did it, the log shows the
original URI, _not_ the actual CGI path). The server then executes the CGI.
Next week I'll have to check which parameter that is...

Quote:> Another thing is also if it (Ent 2.01) can run cgi's outside the
> /cgi-bin dir (the guys there said it can't) and how to set up this..[*1]
> If you can, can you run a cgi named foo.html as a cgi or is the
> .extension the main match to determine what to do? [*2]

There's no built-in way to do that, but you might be able to either write a
custom NSAPI function or use something like

<Object ppath="/full/fs/path/to/foo.html">
Service type="*" fn="send-cgi"
</Object>

...maybe!

-Peter

 
 
 

Can Nscp-Enterprise 2.01 do internal rewrite/redirect

Post by Peter » Thu, 06 Jan 2000 04:00:00




> > The setup they have is all cgi-bin's in
> > /cgi-bin dir and also they don't know much what NscpEnt can/can't do. To
> > match their requirements I'd like to make sure if Ent 2.01 can do an
> > equivalent of Apache's mod_rewrite's:

> > RewriteRule ^/path/to/file$ /cgi-bin/foo.cgi

> > which means the browser still thinks it's getting content from
> > /path/to/file while it's actually getting a result from a cgi..Otherwise
> > i'll be having problems with relative links we're using..

1) Make a NSAPI function that does something like this, which I tested on
FastTrack 2.01:

/* Netscape NSAPI header files */
#include "netsite.h"
#include "base/session.h"
#include "base/pblock.h"
#include "frame/req.h"
#include "frame/http.h"
/* our PW-internal-redirect function */
int PW_internal_redirect(pblock *pb, Session *sn, Request *rq) {
        char *cgiPath;
        char *apparentPath;
        /* check parameters and ppath value (you could obviously change
            from strcmp() to a regexp compile/comparison if needed) */
        if (  ((cgiPath=pblock_findval("cgiPath",pb)) == NULL)
                || ((apparentPath=pblock_findval("apparentPath",pb)) == NULL)
                || (strcmp(apparentPath, pblock_findval("ppath", rq->vars)) !=
0) )
                        return REQ_NOACTION;
        /* looks like a match, clear the current ppath */
        if ( param_free(pblock_remove("ppath", rq->vars)) ) {
                /* make the rest of the httpd stuff think they requested
something else */
                pblock_nvinsert("ppath", cgiPath, rq->vars);
        }
        /* and we return from the function */
        return REQ_NOACTION;

Quote:}

2) Init your function in obj.conf and call it as a NameTrans function

# at the top
Init fn=load-modules shlib=/path/to/libMyRedirect.so
funcs="PW-internal-redirect"

# in an Object
# note both Path's are actually URI's, not Unix fs paths
NameTrans fn="PW-internal-redirect" apparentPath="/old/uri"
cgiPath="/cgi-bin/foo.cgi"

3) If you call this outside the "default" Object in obj.conf, you *might* need
to add something like the following three lines to that Object to make sure
the httpd runs the CGI as expected.

NameTrans fn="pfx2dir" from="/cgi-bin" dir="/full/unix/path/to/cgi-bin"
ObjectType fn="force-type" type="magnus-internal/cgi"
Service fn="send-cgi"

That's it.

-Peter

 
 
 

1. Redirection Problem in Netscape Enterprise Server 2.01

I have a problem with Netscape Enterprise Server 2.01.

If I have a URL

http://blahdev/cgi/prog?param1=x

and we use Netscape redirection to redirect blahdev to blahprod
then the parameter is lost i.e. it is translated to

http://blahprod/cgi/prog

Is there any way around this
(to get the parameters transferred as well).??

Thanks,
Greg Toomey.

2. Looking for Tru64 Experts

3. Netscape Enterprise 2.01 not working as advertised on HPUX 10.10

4. Diamont

5. Netscape Enterprise 2.01 Trial Expiry Question

6. recovering tar files from tape

7. Netscape Enterprise 2.01 Vs Apache 1.2.4

8. wine and dosemulator

9. NS Enterprise 2.01 running too many processes

10. Netscape Enterprise 2.01 + SSL patch: extreme memory demands ?

11. Netscape Enterprise 2.01 and Berkeley DB ?

12. Netscape Enterprise 2.01 & Sun Solaris upgrade

13. Enterprise 2.01 - connection reset by peer