Configuring external CGI script in Tomcat 8.5

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Configuring external CGI script in Tomcat 8.5

Jean-Pierre Urkens
Can anyone clarify on how to configure Tomcat 8.5 to serve an external
executable? The CGI-HowTo documentation is VERY unclear to me.

So let's say I have an application installed under 'c:\myApp' that provides
a CGI executable 'c:\myApp\cgi\myapp.exe' now how do I configure Tomcat to
have requests to http://localhost/myApp to call the c:\myApp\cgi\myapp.exe
executable?

 

I tried to add a context.xml file named myapp.xml to
{TOMCAT_BASE}\conf\catalina\localhost with following content:

 

<Context displayName= "myApp" docBase="C:\myApp\cgi\" path="/myApp"
reloadable="false" privileged="true" swallowOutput="true"
workDir="work\Catalina\localhost\myApp">

</Context>

 

But that doesn't seem to work, it will try to download the myapp.exe file.

 

Any instructions are welcome.

 

Reply | Threaded
Open this post in threaded view
|

Re: Configuring external CGI script in Tomcat 8.5

Christopher Schultz-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jean-Jierre,

On 6/23/20 08:55, [hidden email] wrote:
> Can anyone clarify on how to configure Tomcat 8.5 to serve an
> external executable? The CGI-HowTo documentation is VERY unclear to
> me.
>
> So let's say I have an application installed under 'c:\myApp' that
> provides a CGI executable 'c:\myApp\cgi\myapp.exe' now how do I
> configure Tomcat to have requests to http://localhost/myApp to call
> the c:\myApp\cgi\myapp.exe executable?

Is myapp.exe a CGI-aware program? Or do you need to proxy from
HTTP-CGI to some intermediate communication language and back again?

> I tried to add a context.xml file named myapp.xml to
> {TOMCAT_BASE}\conf\catalina\localhost with following content:

You can also bundle this file into your web application under
META-INF/context.xml which may (or may not) be more convenient.

> <Context displayName= "myApp" docBase="C:\myApp\cgi\"
> path="/myApp" reloadable="false" privileged="true"
> swallowOutput="true" workDir="work\Catalina\localhost\myApp">
>
> </Context>

Remove the "path" attribute: it's not legal in this location. The name
of the file (myapp[.xml]) dictates the context path.

> But that doesn't seem to work, it will try to download the
> myapp.exe file.

Did you modify web.xml in any particular way? If not, it's never going
to work because all you have done is deploy a web application hosted
at C:\myapp\cgi".

Just because a file is named .exe doesn't make it special in any way.
How else would you download .exe files if they were always executed
when you requested them?

In order to use CGI, you need to configure the CGI servlet.

The documentation can be found here:
http://tomcat.apache.org/tomcat-8.5-doc/cgi-howto.html

Give that a read and see if you can get further.

Please understand that CGI on Windows is essentially impossible to run
securely if you need to pass command-line arguments provided by the
client to the script. Please see the Security Considerations[1] page
and search for CGI for more information.

- -chris

[1] https://tomcat.apache.org/tomcat-8.5-doc/security-howto.html
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl7yIKYACgkQHPApP6U8
pFjPiBAAikmoEQtUsztMRYC6aa2OYARZjMMo7pxZ8aVA3leQdwWkiSfC29AVCgGO
KpQalDRtWTiJaV4doVVaqynSGjgO/2f9XyZxXyWjstMKbkkAFZez13P4dMPYS5H7
C55yLKE+Ay3oDm+nvoihoXQK76wKj0b10/vzuzSv8zf68i6fbd8jC/s2zZpBOYcr
VaEGsd7KQIaQ+JxZ4OBk5/h/In9I9ouv0Mp2dvRg0OC1r9MAYPZoU0X+XladqEsP
YjGFHFkICBPC8YO0baZ22vkw6v7JXIBQO0JKxIjCDnLqDKSbTI914pVlxrCWetZO
wzpU4XXK8qvuyY+BhsosUoJll3DdTjkfyEnTGUV8AahRFSWJr87f0Fp3rMmuYCq2
C/i/CMrhXvwj/3/eWQDkN4qngz6fVlqbw8m/gxzy0YO1+pplf0ek5t30d7S/LZV/
WwgXZbvjDRtRQIChRkorw/4EnBcoKZ139OFmLXl3PCDpqJSlUQ1IlwoWgI8Ww6AJ
W/oVmhdX0gGxCc2HGAUFOjcT20o6tYALymVjnCNOlMfJV9dtOq99lUb/UdrXDWKb
yXIIomg8zZxKDq4a5499uYo3eeYioclObQI1C3Ej0L0jTGHzkcRl0EOOTa0MKpnn
lEBJDCYGXa6p81f4/O5GqFzZHv5UiRvcLzug5sfhqI5leESunIY=
=8RaV
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]