Forum Discussion

AloysiusPendergast's avatar
AloysiusPendergast
Copper Contributor
Aug 16, 2023

Unexpected behavior of an CGI.EXE under Windows Server 2022

I hope this is the right place for my question. I coded a simple example in C under Visual Studio 2022 with the following short code:

#include <stdio.h>
main()
{
    printf("Content-type:text/plain\n\n");
    printf("Hello World from C returen 1\n");
    return(1);
}

 

If I “execute” it on my local machine (Windows 11 & IIS) via the browser (localhost/cgi/cgi.exe) everything works as expected. In the Broser I can read the “Hello World from C” string.

If I execute it on my Virtual Windows Server 2022 in the same way (regardless of whether I test it, locally or over the internet. I get the following error message:

via the internet

502 - Web server received an invalid response while acting as a gateway or proxy server.

There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.


and if I execute it locally on the server I got this error message:

HTTP Error 502.2 - Bad Gateway

The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are ""

 

It seems that in this case the cgi.exe dos not write anything at  stdout, but why only if it is executed on the Windows Server? The IIS configurations are the same as on my local win11 machine.

By the way if I do the same with a similar cgi excutable programmed in c# it works in both cases as expected.

Has anyone an idea what causes this problem?

Thanks,
Thomas

No RepliesBe the first to reply

Resources