Customer Recommended How to
Configure WebLogic Server to Capture Client IP Addresses Behind a Load Balancer
Using Extended Log Format (Doc ID 1602379.1)
1- Log into your WLS machine, and run the $WL_HOME/server/bin/setWLSEnv.sh script to initialize the necessary environment variables, such as location of java, and javac (compiler) that you will need.
In a text editor, create a file called, for example, "GWXFF.java"
with the following:
[oracle@test~]$ vi GWXFF.java
[oracle@test scripts]$ cat GWXFF.java
import weblogic.servlet.logging.CustomELFLogger;
import weblogic.servlet.logging.FormatStringBuffer;
import weblogic.servlet.logging.HttpAccountingInfo;
/* This example outputs the X-Forwarded-For
* field into a custom field called GWXFF
* */
public class GWXFF implements CustomELFLogger{
public void logField(HttpAccountingInfo metrics, FormatStringBuffer buff) {
buff.appendValueOrDash(metrics.getHeader("X-Forwarded-For"));
}
}
[oracle@test bin]$ cd
/u01/install/APPS/fs2/FMW_Home/wlserver_10.3/server/bin
[oracle@test bin]$ . setWLSEnv.sh
CLASSPATH=/u01/install/APPS/fs2/FMW_Home/patch_wls1036/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/u01/install/APPS/fs2/EBSapps/comn/util/jdk64/lib/tools.jar:/u01/install/APPS/fs2/FMW_Home/wlserver_10.3/server/lib/weblogic_sp.jar:/u01/install/APPS/fs2/FMW_Home/wlserver_10.3/server/lib/weblogic.jar:/u01/install/APPS/fs2/FMW_Home/modules/features/weblogic.server.modules_10.3.6.0.jar:/u01/install/APPS/fs2/FMW_Home/wlserver_10.3/server/lib/webservices.jar:/u01/install/APPS/fs2/FMW_Home/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/u01/install/APPS/fs2/FMW_Home/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:/u01/install/APPS/fs2/EBSapps/comn/util/jdk32/lib/dt.jar:/u01/install/APPS/fs2/EBSapps/comn/util/jdk32/lib/tools.jar:/u01/install/APPS/fs2/EBSapps/comn/util/jdk32/jre/lib/rt.jar:/u01/install/APPS/fs2/EBSapps/comn/shared-libs/ebs-3rdparty/WEB-INF/lib/ebs3rdpartyManifest.jar:/u01/install/APPS/fs2/FMW_Home/Oracle_EBS-app1/shared-libs/ebs-fmw/WEB-INF/lib/ebsFMWManifest.jar:/u01/install/APPS/fs2/FMW_Home/Oracle_EBS-app1/shared-libs/ebs-appsborg/WEB-INF/lib/ebsAppsborgManifest.jar:/u01/install/APPS/fs2/FMW_Home/oracle_common/modules/oracle.uix_11.1.1/uix2.jar:/u01/install/APPS/fs2/EBSapps/comn/java/classes:/u01/install/APPS/fs2/EBSapps/10.1.2/forms/java:/u01/install/APPS/fs2/EBSapps/10.1.2/forms/java/frmall.jar:/u01/install/APPS/fs2/EBSapps/10.1.2/jlib/ewt3.jar:/u01/install/APPS/fs2/EBSapps/10.1.2/j2ee/OC4J_BI_Forms/applications/formsapp/formsweb/WEB-INF/lib/frmsrv.jar
PATH=/u01/install/APPS/fs2/FMW_Home/wlserver_10.3/server/bin:/u01/install/APPS/fs2/FMW_Home/modules/org.apache.ant_1.7.1/bin:/u01/install/APPS/fs2/EBSapps/comn/util/jdk64/jre/bin:/u01/install/APPS/fs2/EBSapps/comn/util/jdk64/bin:/u01/install/APPS/fs_ne/EBSapps/appl/ad/bin:/u01/install/APPS/fs2/FMW_Home/modules/org.apache.ant_1.7.1/bin:/u01/install/APPS/fs2/inst/apps/QA_ebsqaapp01/admin/scripts:/u01/install/APPS/fs2/FMW_Home/webtier/perl/bin:/u01/install/APPS/fs2/EBSapps/10.1.2/bin:/u01/install/APPS/fs2/EBSapps/appl/fnd/12.0.0/bin:/u01/install/APPS/fs2/EBSapps/appl/ad/12.0.0/bin:/u01/install/APPS/fs2/EBSapps/comn/util/jdk32/jre/bin:/u01/install/APPS/fs2/EBSapps/comn/util/jdk32/bin::/u01/install/APPS/fs2/EBSapps/10.1.2/OPatch:/u01/install/APPS/fs2/EBSapps/10.1.2/bin:/usr/bin:/usr/sbin:/u01/install/APPS/fs2/EBSapps/comn/util/jdk32/jre/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/oracle/.local/bin:/home/oracle/bin
Your environment has been set.
3- Compile this file as follows
[oracle@test scripts]$ javac GWXFF.java
You will now have a file called GWXFF.class.
[oracle@test scripts]$ ll
-rw-r-----. 1 oracle oinstall 675 Jun 11 11:29 GWXFF.class
-rw-r-----. 1 oracle oinstall 441 Jun 11 11:29 GWXFF.java
4- Next, create a jar package out of the GWXFF.class file.
[oracle@test scripts]$ jar cvf GWXFF.jar
GWXFF.class
added manifest
adding: GWXFF.class(in = 675) (out= 370)(deflated 45%)
[oracle@test scripts]$ ll
total 28
-rwxr-xr-x. 1 oracle oinstall 4866 May 29 09:58
cmclean.sql
-rw-r-----. 1 oracle oinstall 675 Jun 11 11:29 GWXFF.class
-rw-r-----. 1 oracle oinstall 825 Jun 11 13:49 GWXFF.jar
-rw-r-----. 1 oracle oinstall 441 Jun 11 11:29 GWXFF.java
-rwxr-xr-x. 1 oracle oinstall 266 May 29 10:12 startprimary.sh
-rwxr-xr-x. 1 oracle oinstall 445 May 29 10:09 stopprimary.sh
Place this jar file at a location that is visible to the managed
servers.
/u01/install/PANSOFT/abd/scripts/GWXFF.jar
5- Add the Custom jar File to the CLASSPATH.
If you are starting
managed servers from the admin console, and you do NOT have start scripts
enabled for Node Manager, follow these steps:
- Log into the Admin Console as the WebLogic Admin user.
Navigate to Environment -> Servers -> Click on name of managed
server. Then select Configuration and Server Start.
- Under "Class Path", add the absolute path to
the GWXFF.jar file from above.
- Click Save, you will be prompted to restart the server.
But do not restart it yet.
If you are starting
managed servers separately from the admin console or have start scripts
enabled, add the absolute path to the GWXFF.jar to the classpath in the managed
server start script.
6- Configuring Extended Log Format.
- While still logged into the Admin console, browse to
Servers -> Managed Server -> Logging -> HTTP -> Advanced and
select Format.
- Change from "Common" to "Extended."
- In the Extended Logging Fields, add "x-GWXFF"
to the fields already there.
- Click save.
- You may be informed that these changes do not require a
restart, when in fact they do.
- Restart the managed server.




No comments:
Post a Comment