LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
SetEnvif User-Agent "^ELB-HealthChecker" ELB
CustomLog logs/elb_log combined env=ELB
SetEnvIf REMOTE_ADDR "(.+)" CLIENTIP=$1
SetEnvIf X-Forwarded-For "^([0-9.]+)" CLIENTIP=$1
LogFormat "%{CLIENTIP}e %D %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" xforward_combined
CustomLog logs/access_log xforward_combined env=!ELB
For IIS similar results can be achieved by installing the advanced logging plugin. After installing this plug in, you need to restart the IIS Manager if it was open during the installation. To actually log the xforward headers create a log file with the X-Forwarded-For request header included:
- Go to the "Advanced Logging" snap in under the IIS section of either individual website home pages in IIS Manager, or under the server home page in IIS Manager. If you would like Advanced Logging configured for all sites hosted on this particular instance, select the latter.
- Under Advanced Logging, click on "Edit Logging Fields" under the Actions pane on the right side of the screen.
- In this window, click on "Add Field".
- Within this dialog, populate the fields with the following values:
-- Field ID: X-Forwarded-For
-- Category: Default
-- Source type: Request Header
-- Source name: X-Forwarded-For
- Click OK on both the Add Field Dialog and the Edit Logging Fields dialog.
- Click on the Logging Defintion named %COMPUTERNAME%-Server and then select "Edit Log Definition" on the Actions pane on the right side of the screen (you can also create your own logging definition by clicking on the "Add Log Definition" link).
- Within the Edit/Add Log Definition dialog, click on the "Select Fields" button (you will also need to fill in additional information if you are adding a new log definition).
- Within the Select Fields dialog, check "X-Forwarded-For" and click OK.
- Click on "Apply" under the Actions pane.
- Restart IIS either through the IIS Manager or by issuing an iisreset command from the command line.
No comments:
Post a Comment