Skip to main content

Configuring the Runtime Environment

This section details configuring the Nexus Repository runtime with recipes for specific tasks. Configuration is separated into the following categories: the Java Virtual Machine and the Nexus Application environments.

See the Directories topic on the $install-dir and $data-dir in Nexus Repository.

Java Virtual Machine Environment

The startup of the Nexus Repository Java Virtual Machine (JVM) is managed within the installation directory. The application startup loads JVM arguments from the Java properties file.

$install-dir/bin/nexus.vmoptions

To edit Java options:

  1. Open $install-dir/bin/nexus.vmoptions in a text editor

  2. Specify each Java option on a new line.

  3. Save the file with permission and ownership of the user who owns the Nexus Repository process.

-Xms2703m
-Xmx2703m
-XX:MaxDirectMemorySize=2703m
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Dkaraf.log=../sonatype-work/nexus3/log
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
-Djava.endorsed.dirs=lib/endorsed

Memory

Before changing the default memory settings, review the memory guidelines. Changing settings requires adjusting all 3 values. The -Xms and -Xmx settings must always have the same value.

See Memory Requirement

  1. Locate the lines that configure memory:

    -Xms2703M
    -Xmx2703M
    -XX:MaxDirectMemorySize=2703M
  2. Edit the values of each setting using the following format. The size is a number and the literal unit letters represent gigabytes (g,G) , megabytes (m,M), or kilobytes (k,K).

    -Xmssize[g|G|m|M|k|K]
    -Xmxsize[g|G|m|M|k|K]
    -XX:MaxDirectMemorySize=size[g|G|m|M|k|K]

Overriding the Java Version in Container Environments

Starting with the Nexus Repository 3.78 release, the nexus.vmoptions file no longer applies to Docker images. Instead, users must now configure JVM options using the INSTALL4J_ADD_VM_PARAMS environment variable.

See the Nexus Repository Docker Container README for details.

DNS Caching in Cloud Environments

Java's default DNS caching may cause connection issues in dynamic AWS environments where resource IPs change. Configure the JVM's DNS cache Time-To-Live (TTL) to 5 seconds to ensure your application quickly adapts to these changes. This is highly recommended when using an external database such as RDS in failover scenarios.

-Dnetworkaddress.cache.ttl=5

See documentation from AWS on TTL for DNS

Data Directory

The Data Directory is used to store the content that you want to preserve.

Set the value as an absolute path or a path relative to the $install-dir/bin directory.

-Dkaraf.data=/opt/sonatype-work/nexus3
-Djava.io.tmpdir=/opt/sonatype-work/nexus3/tmp
-XX:LogFile=/opt/sonatype-work/nexus3/log/jvm.log
-Dkaraf.log=/opt/sonatype-work/nexus3/log

Temporary Directory

Nexus Repository uses the Java virtual machine temporary directory for downloading and editing files. The temporary directory is set inside the data directory to isolate file ownership and permissions under a single directory tree.

To change the location of the temporary directory, edit the following line:

-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
  • Do not manipulate files in the temp directory

  • Make sure the disk has more than 1GB of free space

  • Do not use the noexec mount option for the location that contains the tmp directory

    The tmp directory requires exec permissions by the user owning the repository manager process. When noexec is set on the tmp directory, Nexus Repository fails on start-up with the following message:

    java.lang.UnsatisfiedLinkError
    failed to map segment from shared object: Operation not permitted

Overriding the License File Location

Override the default location of where the license is stored by modifying the Java user preferences. This method only works for Linux and MacOS environments. The location must be an absolute path that is readable by the user account owning the repository manager process. This is the directory where the product license is written when installed.

  1. Find and edit the <app_dir>/bin/nexus.vmoptions file.

  2. At the end of the file, add a new line including the following property:

    -Djava.util.prefs.userRoot=/absolute/path/to/already/created/directory

Nexus Application Environment

The main location for the application configuration files is the $install-dir/etc directory. This directory includes one properties file and several nested directories:

  • fabric

    Configuration files for Ehcache, Elasticsearch, and OrientDB

  • karaf

    Configuration files for Apache Karaf, including:

    • config.properties

      The main configuration for the Apache Karaf runtime. This file should not be modified.

    • custom.properties

      Customizable configuration used by Apache Karaf. This file can be used to pass additional parameters to the Apache Karaf container.

    • org.apache.*, org.ops4j.*

      Various Karaf and OSGi-related configuration files

    • system.properties

      System properties used for the JVM and application start-up

  • jetty

    Eclipse Jetty is used as the webserver for the Nexus Repository application. We manage configuration files for Eclipse Jetty in this directory.

    See changing the thread pool as an example of this configuration.

  • logback

    Logger definition for the log file name, logging levels, pattern layout, and rotation rules. The configuration files for logback including:

    See Logging for information on adjusting the logging configuration.

    • logback.xml

      For the nexus.log and tasks.log files

    • logback-access.xml

      For the request.log file

  • ssl

    A directory to put keystores when configuring HTTPS

    See Configuring SSL for details.

nexus-default.properties

$install-dir/etc/nexus-default.properties

This file contains the system default property values such as the main HTTP connector port and the context path. This file should not be modified rather configuration changes should be maintained in the nexus.properties file stored in the data directory.

Keeping the application configuration in the data directory simplifies upgrading as when new application properties are added you do not have to find the difference between the two files.

nexus.properties

$data-dir/etc/nexus.properties

Configuration stored in the nexus.properties file overrides the settings found the nexus-default.properties file. This file provides a more simple upgrade process as custom configuration is maintained separately from the default application configuration.

The $data-dir/etc/nexus.properties file is created the first time Nexus Repository is started. When you need to add configuration before the the first start-up, manually created file with any of the customizations stored there.

Application Port

We recommend configuring Nexus Repository behind a proxy server when directing traffic from the domain to the service. From the running server, you may access the service directly using the localhost and the default port for the application, 8081.

http://localhost:8081/

Set the port by adding the following line to your nexus.properties file:

application-port=8081

See Setting up SSL to use a secured port instead of HTTP.

Application Context Path

The application context path is the directory found after the domain name in the sites URL. By default, this value is set to a slash (/) to locate the service at the root of the domain.

The location may be changed by setting the nexus-context-path property in the nexus.properties file.

nexus-context-path=/nexus

In the above configuration, the exposed URL is now https://your_url.domain/nexus/