Maury Markowitz
2003-07-08 12:12:01 UTC
I solved this some time ago, but I'm not sure I posted the results to the group. This is a definite FAQ, so:
On NT it is not possible to retrieve the client's IP address using the request.headerForKey("x-webobjects-remote-addr"); call, the header in question is not placed into the dictionary.
After a bit of poking about I discovered this is due to a bug in the Apple-supplied IIS web adaptor. The bug is that the Apple code uses ALL_RAW as the key into IIS to retrieve the header information, which the IIS documentation clearly states returns the headers supplied by the client browser only. Things like the client IP address are added by the server, and don't appear in ALL_RAW.
The solution is to modify the copyHeaders method of WebObjects.c in the IIS subproject to make additional calls to IIS to retrieve these headers, and then copy them into the output. The existing code esssentially makes a single call using ALL_RAW and the parses the results. You should add additional code to retrieve the server-side headers as well.
Just above the line:
if (p->GetServerVariable(p->ConnID, "ALL_RAW", stackBuf, &bufsz) == TRUE)
...you should add additional calls like:
buf = getHeader(p, "REMOTE_ADDR");
req_addHeader(req, "REMOTE_ADDR", buf, STR_COPYKEY|STR_COPYVALUE);
WOFREE(buf);
There are a number of such calls I recommend, AUTH_USER, AUTH_PASSWORD, AUTH_TYPE, LOGON_USER, REMOTE_ADDR, REMOTE_HOST, REMOTE_USER. This makes the IIS adaptor work like any other and the "normal" method of getting the client IP address will now work fine.
Recompile, install and enjoy!
Maury
On NT it is not possible to retrieve the client's IP address using the request.headerForKey("x-webobjects-remote-addr"); call, the header in question is not placed into the dictionary.
After a bit of poking about I discovered this is due to a bug in the Apple-supplied IIS web adaptor. The bug is that the Apple code uses ALL_RAW as the key into IIS to retrieve the header information, which the IIS documentation clearly states returns the headers supplied by the client browser only. Things like the client IP address are added by the server, and don't appear in ALL_RAW.
The solution is to modify the copyHeaders method of WebObjects.c in the IIS subproject to make additional calls to IIS to retrieve these headers, and then copy them into the output. The existing code esssentially makes a single call using ALL_RAW and the parses the results. You should add additional code to retrieve the server-side headers as well.
Just above the line:
if (p->GetServerVariable(p->ConnID, "ALL_RAW", stackBuf, &bufsz) == TRUE)
...you should add additional calls like:
buf = getHeader(p, "REMOTE_ADDR");
req_addHeader(req, "REMOTE_ADDR", buf, STR_COPYKEY|STR_COPYVALUE);
WOFREE(buf);
There are a number of such calls I recommend, AUTH_USER, AUTH_PASSWORD, AUTH_TYPE, LOGON_USER, REMOTE_ADDR, REMOTE_HOST, REMOTE_USER. This makes the IIS adaptor work like any other and the "normal" method of getting the client IP address will now work fine.
Recompile, install and enjoy!
Maury