Repository Management with Nexus
3.7. Running Nexus Behind a Proxy

3.7. Running Nexus Behind a Proxy

If you installed Nexus as a stand-alone application, Nexus is running on a high-performance servlet container based on Java NIO. From a performance perspective, there is no reason for you not to run Nexus by itself without a proxy. Yet, more often than not, organizations run applications behind a proxy for security concerns and to consolidate multiple disparate applications using tools like mod_rewrite and mod_proxy. For this reason, we've included some brief instructions for configuration mod_proxy in Apache httpd. We assume that you've already installed Apache 2, and that you are using a Virtual Host for www.somecompany.com.

Let's assume that you wanted to host Nexus behind Apache HTTPd at the URL http://www.somecompany.com. To do this, you'll need to change the context path that Nexus is served from.

  1. Edit plexus.properties in ${NEXUS_HOME}/conf. You'll see an element named webapp-context-path. Change this value from "/nexus" to "/"

  2. Restart Nexus and Verify that it is available on http://localhost:8081/.

  3. Clear the Base URL in Nexus as shown in Figure 6.3, “Nexus Server Configuration (App Server and HTTP Proxy Config)” under Application Server Settings.

At this point, edit the HTTPd configuration file for the www.somecompany.com virtual host. Include the following to expose Nexus via mod_proxy at http://www.somecompany.com/.

ProxyRequests Off 
ProxyPreserveHost On 

<VirtualHost *:80> 
  ServerName www.somecompany.com 
  ServerAdmin admin@somecompany.com 
  ProxyPass / http://localhost:8081/
  ProxyPassReverse / http://localhost:8081/
  ErrorLog logs/somecompany/nexus/error.log 
  CustomLog logs/somecompany/nexus/access.log common 
</VirtualHost>

If you just wanted to continue to serve Nexus at the /nexus context path, you would not change the contextPath in ${NEXUS_HOME}/conf/plexus.xml and you would include the context path in your ProxyPass and ProxyPassReverse directives as follows:

  ProxyPass /nexus/ http://localhost:8081/nexus/
  ProxyPassReverse /nexus/ http://localhost:8081/nexus/

Apache configuration is going to vary based on your own application's requirements and the way you intend to expose Nexus to the outside world. If you need more details about Apache httpd and mod_proxy, please see http://httpd.apache.org.

Sonatype Promotion Subscribe via RSS