# Nexus

Sonatype Nexus Repository is an artifact and package repository manager for storing and proxying binaries such as Maven, npm, NuGet, Docker, and PyPI components. It gives your build pipelines a single, reliable source for dependencies and release artifacts. The web UI runs on port 8081.

## Software included

| Component | Version |
| --- | --- |
| Nexus Repository | 3.94.0 |
| Ubuntu | 24.04 LTS |

## Environment variables

Set these optionally when you deploy from the marketplace. Leave a field blank to have a secure value generated.

| Variable | Description |
| --- | --- |
| `NEXUS_ADMIN_PASSWORD` | Nexus admin password |

## Getting started

### 1. Connect to your VM

```bash
ssh ubuntu@<your-vm-ip>
```

### 2. Wait for first-boot configuration

Nexus starts from its pre-installed Docker image and generates a unique initial admin password. Initialization can take several minutes. Track progress with:

```bash
sudo journalctl -u nexus-first-boot.service -f
```

Then verify the container:

```bash
cd /opt/nexus && docker compose ps
```

### 3. Access the Nexus UI

Open a browser and navigate to:

```text
http://<your-vm-ip>:8081
```

Read the generated login details:

```bash
sudo cat /etc/nexus/credentials.txt
```

| Field | Value |
| --- | --- |
| Username | `admin` |
| Password | From `/etc/nexus/credentials.txt` |

Complete the setup wizard, change the admin password, and choose your anonymous-access policy.

## Managing Nexus

Nexus runs as a Docker Compose stack in `/opt/nexus`.

```bash
# Check status
cd /opt/nexus && docker compose ps


# Restart
cd /opt/nexus && docker compose restart


# View logs
cd /opt/nexus && docker compose logs -f
```

| Path | Purpose |
| --- | --- |
| `/opt/nexus/docker-compose.yml` | Compose stack |
| `/var/lib/nexus/` | Persistent repository data |
| `/var/lib/nexus/admin.password` | Initial password generated by Nexus |
| `/etc/nexus/credentials.txt` | First-login details |

## Security

Port 8081 is open on the VM’s network interface. UFW is enabled and allows Nexus (port 8081) and SSH (port 22).

To restrict the UI and repository API to a specific IP:

```bash
sudo ufw delete allow 8081/tcp
sudo ufw allow from <trusted-ip> to any port 8081
```

To access Nexus without leaving port 8081 open, use an SSH tunnel:

First close the public port on the VM, since it is open by default:

```bash
sudo ufw delete allow 8081/tcp
```

```bash
# Run this on your local machine
ssh -L 8081:localhost:8081 ubuntu@<your-vm-ip>


# Then open in a browser
http://localhost:8081
```

For production use, place Nexus behind a reverse proxy with a trusted TLS certificate and restrict direct access to administrator and CI/CD networks.

Complete the setup wizard and change the generated initial admin password before using Nexus. Keep `/etc/nexus/credentials.txt` restricted to trusted administrators.

## Next steps

- [Nexus documentation](https://help.sonatype.com/en/sonatype-nexus-repository.html)
- [Nexus installation guide](https://help.sonatype.com/en/installation.html)
