{"id":10801,"date":"2021-10-24T10:30:58","date_gmt":"2021-10-24T07:30:58","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10801"},"modified":"2024-03-18T13:26:49","modified_gmt":"2024-03-18T10:26:49","slug":"run-nexus-repository-manager-behind-apache-reverse-proxy","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/run-nexus-repository-manager-behind-apache-reverse-proxy\/","title":{"rendered":"Run Nexus Repository Manager Behind Apache Reverse Proxy"},"content":{"rendered":"\n
Follow through this tutorial to learn how to run Nexus repository manager behind Apache reverse proxy. According Reverse proxy guide page<\/a>, 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<\/em>.<\/p>\n\n\n\n In our previous tutorial, we learnt how to install Nexus repository manager;<\/p>\n\n\n\n Install Nexus Repository Manager on Debian 11<\/a><\/p>\n\n\n\n Install Nexus Repository Manager on Ubuntu 20.04<\/a><\/p>\n\n\n\n Install Nexus Repository Manager on Debian 10<\/a><\/p>\n\n\n\n In all the above tutorials, Nexus port 8081 is exposed to the external networks as can be seen on Nexus URL, When you run Nexus repository behind a reverse proxy, you can access it without having to specify its port on the URL.<\/p>\n\n\n\n NOTE: if your Nexus instance is already listening on a loopback address, then skip this step.<\/p>\n\n\n\n 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.<\/p>\n\n\n\n Before you can proceed, first configure Nexus to bind it to a loopback interface, As shown by the To bind Nexus to localhost interface, replace the 0.0.0.0 address in the configuration file above;<\/p>\n\n\n\n Once you have made the changes, restart Nexus;<\/p>\n\n\n\n Once Nexus starts, you can confirm the address it is bind to again;<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n Next, install Apache Web server;<\/p>\n\n\n\n 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.<\/p>\n\n\n\n To create the Nexus site configuration, Replace the names of the site accordingly.<\/strong><\/p>\n\n\n\n Verify Apache Syntax;<\/p>\n\n\n\n If the output is, Syntax OK, then you are good to proceed. Otherwise fix any would be errors before you can proceed.<\/p>\n\n\n\n Disable default Apache site;<\/p>\n\n\n\n Enable Apache Nexus site;<\/p>\n\n\n\n Next, you need to enable required Apache proxy modules ( Restart Apache Web server;<\/p>\n\n\n\n You can now access your Nexus without specifying the port on the url.<\/p>\n\n\n\n Run Behind a Reverse Proxy<\/a><\/p>\n\n\n\n Run Nexus Repository Behind Nginx Reverse Proxy<\/a><\/p>\n\n\n\nRunning Nexus Repository Manager Behind Apache Reverse Proxy<\/h2>\n\n\n\n
http:\/\/server-IP:8081<\/code><\/strong>.<\/p>\n\n\n\n
Bind Nexus Repository to Localhost Interface<\/h3>\n\n\n\n
ss -altnp | grep 8081<\/code><\/pre>\n\n\n\n
LISTEN 0 50 0.0.0.0:8081 0.0.0.0:* users:((\"java\",pid=663,fd=691))<\/code><\/pre>\n\n\n\n
127.0.0.1<\/code><\/strong>.<\/p>\n\n\n\n
ss<\/strong><\/code> command output above, Nexus listens on all interfaces on port 8081\/tcp.<\/p>\n\n\n\n
grep application- \/opt\/nexus\/etc\/nexus-default.properties<\/code><\/pre>\n\n\n\n
application-port=8081\napplication-host=0.0.0.0<\/strong><\/code><\/pre>\n\n\n\n
sed -i 's\/0.0.0.0\/127.0.0.1\/' \/opt\/nexus\/etc\/nexus-default.properties<\/code><\/pre>\n\n\n\n
systemctl restart nexus<\/code><\/pre>\n\n\n\n
ss -altnp | grep 8081<\/code><\/pre>\n\n\n\n
LISTEN 0 50 127.0.0.1:8081 0.0.0.0:* users:((\"java\",pid=2711,fd=699))<\/code><\/pre>\n\n\n\n
Install Apache Web Server<\/h3>\n\n\n\n
apt install apache2 -y<\/code><\/pre>\n\n\n\n
Running Nexus Repository Manager Behind Apache Reverse Proxy<\/h3>\n\n\n\n
Create Apache Nexus Site Configuration<\/h4>\n\n\n\n
\/etc\/apache2\/sites-available\/nexus.conf<\/code>, you can simply copy and paste the content below on the terminal.<\/p>\n\n\n\n
\ncat > \/etc\/apache2\/sites-available\/nexus.conf<< 'EOL'\nProxyRequests Off\nProxyPreserveHost On\n \n
apachectl -t<\/code><\/pre>\n\n\n\n
a2dissite 000-default.conf<\/code><\/pre>\n\n\n\n
a2ensite nexus.conf<\/code><\/pre>\n\n\n\n
Enable Apache Proxy Modules<\/h4>\n\n\n\n
mod_proxy<\/code> and
mod_proxy_http<\/code>).<\/p>\n\n\n\n
a2enmod proxy proxy_http<\/code><\/pre>\n\n\n\n
systemctl restart apache2<\/code><\/pre>\n\n\n\n
Accessing Nexus running behind Apache Proxy<\/h3>\n\n\n\n
<\/figure>\n\n\n\n
Reference<\/h3>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n