Run Nexus Repository Manager Behind Apache Reverse Proxy

Last Updated:

Follow through this tutorial to learn how to run Nexus repository manager behind Apache reverse proxy. According Reverse proxy guide page, Apache, apart from functioning as a “basic” web server, and providing static and dynamic content to end-users, it ca also act as a reverse proxy server, also-known-as a “gateway” server.

Running Nexus Repository Manager Behind Apache Reverse Proxy

In our previous tutorial, we learnt how to install Nexus repository manager;

Install Nexus Repository Manager on Debian 11

Install Nexus Repository Manager on Ubuntu 20.04

Install Nexus Repository Manager on Debian 10

In all the above tutorials, Nexus port 8081 is exposed to the external networks as can be seen on Nexus URL, http://server-IP:8081.

When you run Nexus repository behind a reverse proxy, you can access it without having to specify its port on the URL.

Bind Nexus Repository to Localhost Interface

NOTE: if your Nexus instance is already listening on a loopback address, then skip this step.

When you check, by default, at least in the guides above, Nexus is not bound to specific interface on a server on which it is running and hence listens on all interfaces on port 8081.

ss -altnp | grep 8081
LISTEN 0      50 *    users:(("java",pid=663,fd=691))

Before you can proceed, first configure Nexus to bind it to a loopback interface,

As shown by the ss command output above, Nexus listens on all interfaces on port 8081/tcp.

grep application- /opt/nexus/etc/

To bind Nexus to localhost interface, replace the address in the configuration file above;

sed -i 's/' /opt/nexus/etc/

Once you have made the changes, restart Nexus;

systemctl restart nexus

Once Nexus starts, you can confirm the address it is bind to again;

ss -altnp | grep 8081

Sample output;

LISTEN 0      50*    users:(("java",pid=2711,fd=699))

Install Apache Web Server

Next, install Apache Web server;

apt install apache2 -y

Running Nexus Repository Manager Behind Apache Reverse Proxy

Once Apache Web server is installed, create Nexus site. Any requests that comes to this site will be forward to the Nexus repository running on the same host on loopback interface.

Create Apache Nexus Site Configuration

To create the Nexus site configuration, /etc/apache2/sites-available/nexus.conf, you can simply copy and paste the content below on the terminal.

Replace the names of the site accordingly.

cat > /etc/apache2/sites-available/nexus.conf<< 'EOL'
ProxyRequests Off
ProxyPreserveHost On

  ServerAdmin [email protected]

  AllowEncodedSlashes NoDecode

  ProxyPass / http://localhost:8081/ nocanon
  ProxyPassReverse / http://localhost:8081/
  ErrorLog ${APACHE_LOG_DIR}/nexus.error.log
  CustomLog ${APACHE_LOG_DIR}/nexus.access.log common


Verify Apache Syntax;

apachectl -t

If the output is, Syntax OK, then you are good to proceed. Otherwise fix any would be errors before you can proceed.

Disable default Apache site;

a2dissite 000-default.conf

Enable Apache Nexus site;

a2ensite nexus.conf

Enable Apache Proxy Modules

Next, you need to enable required Apache proxy modules (mod_proxy and mod_proxy_http).

a2enmod proxy proxy_http

Restart Apache Web server;

systemctl restart apache2

Accessing Nexus running behind Apache Proxy

You can now access your Nexus without specifying the port on the url.

nexus proxied 1


Run Behind a Reverse Proxy

Other Tutorials

Run Nexus Repository Behind Nginx Reverse Proxy

Install and Setup Jenkins on Ubuntu 20.04

Install SonarQube on Ubuntu 20.04


We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
Co-founder of, Linux Tips and Tutorials. Linux/Unix admin and author at

Leave a Comment