Configuring the Runtime Environment

Configuring the specifics of the repository manager runtime involves configuration for all components in various configuration files and startup scripts. This section details these and provides recipes for specific tasks. The startup of the JVM running the repository manager is managed via files in the $install-dir/bin directory within the installation. The application startup is performed with the JVM configuration in the file $install-dir/bin/nexus.vmoptions:

-Xms1200M
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-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
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false

The main location for configuration files is the etc directory. It includes one properties file and a number of nested directories:

$ ls -1 nexus-<version>/etc
fabric
jetty
karaf
logback
nexus-default.properties
ssl

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.* and org.ops4j.* - various Karaf and OSGi related configuration files
    • system.properties - system properties used for the JVM and application start up

jetty

Configuration files for Eclipse Jetty

logback

Configuration files for logback including:

    • logback.xml - Contains default logger definitions for log file names, log levels, pattern layouts and rotation rules for the nexus.log and tasks/*.log files 
    • logback-access.xml - Contains the default logger definition for the log file name, log level, pattern layout and rotation rules for the request.log file

See Logging and Log Viewer for more information on repository manager logging and the recommended approach for adjusting the logging configuration to meet your needs. 

nexus-default.properties

Default properties file for the application providing default values such as the ports used for HTTP and HTTPS access, as well as the context path and host. Override these defaults in $data-dir/etc/nexus.properties. This nexus-default.properties file should not be modified. The defaults in $data-dir/etc/nexus.properties is created the first time Nexus is started. You can copy the nexus-default.properties to $data-dir/etc/nexus.properties and customize before having to start Nexus the first time.

ssl

A directory to put keystores when configuring HTTPS

Updating Memory Allocation and other JVM Parameters

The default and maximum heap sizes for the repository manager are a value of 1200M, suitable for most usage patterns. As a Java application running on the JVM the repository manager is using JVM configuration parameters for numerous settings as part of the startup parameters for the JVM. These values are defined in the configuration file $install-dir/bin/nexus.vmoptions. Increased memory configuration can be set with e.g.:

-Xms1500M
-Xmx2G

Other JVM parameters such as GC algorithm can be configured in the same location.

See our System Requirements Memory section for more information and guidance on specific numbers.

Changing the HTTP Port

The default value for the HTTP port used to access the repository manager user interface and resources is 8081. Therefore the user interface would be available at  http://localhost:8081/. To change or update the port, locate the line application-port=8081 in $data-dir/etc/nexus.properties, then edit the number. Here is an example where you would change the port to 9081:

application-port=9081

Therefore, the exposed URL will be http://localhost:9081/.

Or setup HTTPS

Additionally, or instead, your use case may require you to run your server on HTTPS.  This includes both business policy and usage of some NXRM features or repository formats.  See our security article on setting up SSL for the means to do this.

Changing the Context Path

To change or update the context path in the instance you want point to a specific webapp or component, locate the nexus-context-path=/ line in the $data-dir/etc/nexus.properties. Here is an example where you expose the user interface to a components directory.

nexus-context-path=/components/

Therefore, if the port is set to 9081, the exposed URL will be http://localhost:9081/components/.

Configuring the Data Directory

You can use  $install-dir/bin/nexus.vmoptions  to define a new location for data you want to preserve. In the configuration file change the values of -Dkaraf.data,  -Djava.io.tmpdir and -XX:LogFile to designate an absolute path you prefer to use.The nexus service will look to add the data directory to the absolute path that you configure. For example, to use the absolute path /opt/sonatype-work/nexus3 change the values as follows:

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