Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connections behind a proxy #18

Open
demilatof opened this issue Nov 22, 2023 · 0 comments
Open

Connections behind a proxy #18

demilatof opened this issue Nov 22, 2023 · 0 comments

Comments

@demilatof
Copy link

It seems to me that the registry client doesn't support a connection behind a proxy.
If your Tomcat is configured to work behind a proxy server you could change the DefaultCatalogueFetcher.java by adding:

  /**
   * The proxy server, if it is not null
   */
  Proxy proxy = null;
  
  /**
   * Allows to set a proxy for HttpxURLConnection
   * 
   * @param proxyType The type of proxy (DIRECT/HTTP/SOCKS)
   * @param proxyIpAddress The address of the proxy
   * @param proxyPort  The port of the proxy
   */
  public void setProxy(Proxy.Type proxyType, String proxyIpAddress, Integer proxyPort)
  {
    proxy = new Proxy(proxyType, new InetSocketAddress(proxyIpAddress, proxyPort));
  }

and then modify the connection in fetchCatalogue to use the proxy only if it has been previously created invoking setProxy.

You have to change the last line in

  @Override
  public RegistryResponse fetchCatalogue(String previousETag) throws IOException {
    URL url = new URL("https://" + this.registryDomain + "/catalogue-v1.xml");

    logger.debug("Opening HTTPS connection to {}", url);   
    
    HttpsURLConnection conn = url.openConnection();

to these three lines

    HttpsURLConnection conn = null;
    if (proxy!=null) conn = (HttpsURLConnection) url.openConnection(proxy);
    else conn = (HttpsURLConnection) url.openConnection();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant