I am using WebLogic server 10.x (11g) to deploy and service my applications. However, our production environment consists of a proxy server which is causing troubles if I try to access certain sites.
Therefore, I would love to know if any feasible solution available to resolve this by configuring the proxy server details on our
- WebLogic Environment
- Application Level - I am using Java to develop my applications
Thanks in advance.
There are two possible ways to aaccomplish this.
Let's look at these.
Proxy Configuration in Application Server Let's take WebLogic application server to illustrate the desired configuration
Configure WebLogic Server to Enable Proxy
1. Using WebLogic Administration Console-jvmargs -Dhttp.proxySet=true -Dhttp.proxyHost=server_url -Dhttp.proxyPort=port
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dhttp.proxyHost=server_url -Dhttp.proxyPort=port
Using Programatically
There are several implementations available and let's discuss few approaches which I think would be useful.
Proxy Configuration Using ValuesAs highlights below you can configure a proxy using programatically defined values inside your application.
Configuration with User CredentialsSometimes you may need to provide exact credentials to get through proxy server. Here is an implementation which will help you to achieve this.
The defined Authenticator class can be used to inject credentials to the proxy configuration as below.
In either case you need to implement the usages at program level as given below. Otherwise, proxy communication will not success and end up throwing exceptions.