Nexus server behind an apache2 proxy

the following howto explains how to install a default nexus server behind an apache2 proxy on a debian host.

First install apache and java download nexus and prepare for configuration. You’ll find the latest version of nexus under http://nexus.sonatype.org/downloads/

[codesyntax lang=”bash”]

apt-get install apache2 sun-java6-jdk
wget http://nexus.sonatype.org/downloads/nexus-oss-webapp-VERSION-bundle.tar.gz
mv nexus-oss-webapp-VERSION-bundle.tar.gz nexus.tgz
mv nexus.tgz /usr/local/
cd /usr/local
tar -xf nexus.tgz
ln -s nexus-oss-webapp-VERSION nexus
ln -s /usr/local/nexus/bin/jsw/linux-x86-64/nexus /etc/init.d/nexus
update-rc.d nexus defaults

[/codesyntax]

Change root path of the nexus web application in /usr/local/nexus/conf/plexus.properties from /nexus to /

[codesyntax lang=”bash”]

webapp-context-path=/

[/codesyntax]

Then add a new vhost to apache:

[codesyntax lang=”apache”]

<VirtualHost _default_:80>
        ServerAdmin manuel@coffeebeans.at

        ProxyRequests Off
        ProxyPreserveHost On

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

        LogLevel warn
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

[/codesyntax]

Apache needs some additional modules loaded and nexus has to be started too.

[codesyntax lang=”bash”]

a2enmod rewrite proxy proxy_http
apache2ctl restart
/etc/init.d/nexus start

[/codesyntax]

After this you should be able to access the nexus server via http://nexus-host:8081/ and http://nexus-host/. The first one is the webapp behind the proxy. Of course you have to replace the hostname or create an appropriate /etc/hosts entry.

As described, this setup is a nexus only host without NameVirtualHost configuration. You can add ServerName and ServerAlias if you want to be able to deploy other vhosts. If you want to share the vhost with other applications, just skip the part with changes in the nexus.properties file or change the value to the wanted path. Then you have to use different lines for proxy configuration. For example, if you want too keep /nexus, you have to use

[codesyntax lang=”bash”]

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

[/codesyntax]

Leave a Comment