Kas81
Kas81

Reputation: 53

Proxy Implementation with WebLogic 11g

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

  1. WebLogic Environment
  2. Application Level - I am using Java to develop my applications


Thanks in advance.

Upvotes: 2

Views: 11679

Answers (3)

30thh
30thh

Reputation: 11386

I had a similar problem in my developer environment running WebLogic 14.1.1.0.0 inside Eclipse IDE. I spend a day finding a working solution to configure a proxy server.

Finally I set the variable EXTRA_JAVA_PROPERTIES in startWebLogic.cmd

set EXTRA_JAVA_PROPERTIES=-Dhttp.proxyHost=proxy.example.com -Dhttp.proxyPort=3128 -Dhttps.proxyHost=proxy.example.com -Dhttps.proxyPort=3128 

here is a tiny JSP page to test, if proxy setting are applied to the JVM:

<html>
<body>
<p><%=System.getProperty("http.proxyHost") %></p>
<p><%=System.getProperty("http.proxyPort") %></p>
<p><%=System.getProperty("https.proxyHost") %></p>
<p><%=System.getProperty("https.proxyPort") %></p>
</body>
</html>

There are solutions I tried, but which DID NOT WORK for me:

  • Setting EXTRA_JAVA_PROPERTIES in setDomainEnv.cmd as recommended by Oracle [1]
  • Setting JAVA_OPTIONS in startWebLogic.cmd as recommended by Aviro and Manish Kumar Gupta [2]
  • Setting Server Start Arguments over Administration Console

[1] Configure Proxy Settings for WebLogic Server https://docs.oracle.com/cd/E53672_01/doc.111191/e53673/GUID-36A18CFA-55F1-4D19-B371-A6D15EBF2E24.htm

[2] Proxy server configuration for Weblogic Server !!! https://kumarsoablog.blogspot.com/2016/10/proxy-server-configuration-for-weblogic.html

Upvotes: 0

Ronald Coarite
Ronald Coarite

Reputation: 4736

To configure WebLogic proxy file is modified setDomainEnv.cmd (Windows) that is located in the bin folder of the domain.

For example for the integrated server is here

C: \ Users \ [YOUT USER NAME] \ AppData \ Roaming \ JDeveloper \ system11.1.1.4.37.59.23 \ DefaultDomain \ bin

The following property must be placed on file with the details of your proxy

@REM Estableciendo proxi
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dhttp.proxySet=true -Dhttp.proxyHost=192.168.101.11 -Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=localhost

See the next link

Configure WebLogic Proxi

Upvotes: 0

Aviro
Aviro

Reputation: 2155

There are two possible ways to aaccomplish this.

  1. Configuring WebLogic Env.
  2. Programatically

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
  1. Login into Administration console
  2. Go to Domain -> Environment -> Servers -> Admin Server -> Configuration -> Server Start
  3. Inside Arguments section enter following and save. -jvmargs -Dhttp.proxySet=true -Dhttp.proxyHost=server_url -Dhttp.proxyPort=port
  4. Restart the WebLogic Server

2. Using WebLogic Startup Scripts
  1. Open WebLogic domain configuration script at
  2. Search for the following phrase "JAVA_OPTIONS"
  3. Enter following details after that. set JAVA_OPTIONS=%JAVA_OPTIONS% -Dhttp.proxyHost=server_url -Dhttp.proxyPort=port
  4. Save script and start the WebLogic server

Using Programatically

There are several implementations available and let's discuss few approaches which I think would be useful.

Proxy Configuration Using Values

As highlights below you can configure a proxy using programatically defined values inside your application.

System.setProperty("http.proxyHost", "proxy_url");
System.setProperty("http.proxyPort", "port");
Configuration with User Credentials

Sometimes you may need to provide exact credentials to get through proxy server. Here is an implementation which will help you to achieve this.

import java.net.Authenticator;
import java.net.PasswordAuthentication;


public class MyAuthenticator extends Authenticator {
    private String username;
    private String password;

    public MyAuthenticator(String username, String password){
        this.username = username;
        this.password = password;
    }

    public PasswordAuthentication getPasswordAuthentication () {
        return new PasswordAuthentication (username, password.toCharArray());
    }
}

The defined Authenticator class can be used to inject credentials to the proxy configuration as below.

System.setProperty("http.proxyHost", "proxy_url");
System.setProperty("http.proxyPort", "port");
Authenticator.setDefault (new MyAuthenticator("domain_name\\user_name","password"));

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.

final URL url = new URL(null, urlString, new sun.net.www.protocol.http.Handler());

Upvotes: 5

Related Questions