- Write a RESTful API with Ballerina
- Write a gRPC service with Ballerina
- Write a GraphQL API with Ballerina
- Work with data using queries in Ballerina
- Build a data service in Ballerina
- Build a Change Data Capture (CDC) service in Ballerina
- Work with Large Language Models (LLMs) using natural expressions
- Deploy Ballerina on Kubernetes
- Manage data persistence with bal persist
- Create your first connector with Ballerina
Organizations use repository managers such as JFrog Artifactory or Sonatype Nexus to serve as a caching proxy for a remotely managed repository. The sections below include information about configuring such a caching proxy for Ballerina Central.
Setting up the repository
The organization should have a repository manager hosted on-premises or in the cloud with the following requirements satisfied.
- Support for Maven repository format
- Support for caching proxy repositories
- Support for flexible MIME types
Both JFrog Artifactory and Sonatype Nexus have been tested and verified against the above requirements. The sections below describe how to configure each of them.
Configure Sonatype Nexus
Follow the steps below to configure a Maven proxy repository in Sonatype Nexus that points to Ballerina Central.
-
Log in to your Nexus Repository Manager as an administrator.
-
Navigate to Settings → Repository → Repositories and click Create repository.
-
Select maven2 (proxy) as the recipe.
-
Fill in the repository details.
Field Value Name A unique name for the repository (e.g., ballerina-central-proxy)Remote storage https://api.central.ballerina.io/2.0/maven -
Under the Maven 2 section, ensure Strict Content Type Validation is disabled (unchecked). Ballerina Central serves
.balapackage artifacts alongside customized Maven metadata, and enabling strict content type validation will cause downloads to fail for non-standard MIME types. -
Under the Proxy section, set Maximum metadata age to a low value such as
1minute. This ensures that newly published packages in Ballerina Central are discovered promptly without waiting for a long metadata cache expiry.Note: Setting Maximum metadata age to
0forces Nexus to re-fetch metadata on every request, which may increase latency. A value between1and5minutes is a good balance between freshness and performance. -
Click Create repository to save the configuration.
-
Copy the repository URL displayed on the repository list page. You will use it when configuring the Ballerina client.
Configure JFrog Artifactory
Follow the steps below to configure a Maven remote repository in JFrog Artifactory that proxies Ballerina Central.
-
Log in to your Artifactory instance as an administrator.
-
Navigate to Administration → Repositories and click Create a Repository, then select Remote.
-
Select Maven as the package type.
-
Fill in the repository details.
Field Value Repository Key A unique key for the repository (e.g., ballerina-central-remote)URL https://api.central.ballerina.io/2.0/maven -
Under the Advanced tab, apply the following settings.
-
Block Mismatching MIME Types — Ensure this is disabled. Ballerina Central serves
.balaartifacts that do not conform to standard Maven MIME types. Enabling this option will cause artifact retrieval to fail. -
Bypass HEAD Requests — Ensure this is enabled. Ballerina Central does not fully support HTTP
HEADrequests for all artifact paths. Enabling this bypass ensures that Artifactory falls back to aGETrequest when aHEADrequest fails, preventing resolution errors. -
Metadata Retrieval Cache Period — Set this to a low value such as
60seconds. This controls how long Artifactory caches repository metadata before re-fetching it from the remote. A lower value ensures that newly published packages in Ballerina Central become available in your proxy repository sooner.Note: Setting Metadata Retrieval Cache Period to
0disables caching entirely and fetches metadata on every request, which may impact performance. A value between60and300seconds is a reasonable balance between freshness and performance.
-
-
Click Save & Finish to create the repository.
-
Copy the repository URL from the Artifacts view. You will use it when configuring the Ballerina client.
Setting up the Ballerina client
You can configure only one proxy repository in the <USER_HOME>/.ballerina/Settings.toml file to use in place of Ballerina Central. A typical configuration looks like the following.
[[repository.maven]] id = "<repository-id>" # This ID is used when pushing/pulling packages url = "<repository-url>" username = "<username> or <userId>" accesstoken = "<password> or <accesstoken>" proxyCentral = true
Replace the placeholders as follows.
| Placeholder | Description |
|---|---|
<repository-id> | A unique identifier for the repository entry (e.g., nexus-ballerina-proxy or artifactory-ballerina-proxy) |
<repository-url> | The full URL of the proxy repository you created in Nexus or Artifactory |
<username> or <userId> | Your Nexus or Artifactory username or user ID |
<password> or <accesstoken> | Your Nexus or Artifactory password or access token |
Once the configuration is done, all Ballerina Central calls will be redirected through this Maven-based proxy repository.
Note: Only one
[[repository.maven]]entry withproxyCentral = trueis allowed at a time. If multiple entries haveproxyCentral = true, Ballerina will return an error.