How to Install Nginx Proxy Manager on NixOS Latest

Nginx Proxy Manager is an application that simplifies the management of reverse proxies and related services. Here’s a step-by-step guide on how to install Nginx Proxy Manager on NixOS.

Step 1: Update the Package Manager and Install Required Packages

Open the terminal and update the package manager by running the following command:

$ sudo nixos-rebuild switch --upgrade

Then, install the required packages for Nginx Proxy Manager by running:

$ sudo nix-env -f '<nixpkgs>' -iA nginx-full libressl

Step 2: Download and Extract Nginx Proxy Manager

Navigate to the directory where you want to install Nginx Proxy Manager and download the latest version of the application as a tar.gz file:

$ cd /opt
$ sudo wget https://github.com/jc21/nginx-proxy-manager/releases/download/v2.9.10/nginx-proxy-manager-2.9.10.tar.gz

Extract the downloaded file using the tar command:

$ sudo tar -xzvf nginx-proxy-manager-2.9.10.tar.gz

Step 3: Configure Nginx Proxy Manager

First, create a new configuration file for Nginx Proxy Manager in the /etc/nginx directory:

$ sudo nano /etc/nginx/nginx-proxy-manager.conf

Add the following content to the configuration file:

# nginx-proxy-manager configuration file

http {
    include /etc/nginx/proxy-manager/*.conf;
}

Next, create the configuration directory by running:

$ sudo mkdir /etc/nginx/proxy-manager

Finally, create a new configuration file in this directory:

$ sudo nano /etc/nginx/proxy-manager/nginx.conf

Add the following content to the file:

# nginx configuration for proxy manager

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    server {
        listen 127.0.0.1:81;
        server_name _;
        access_log /var/log/nginx/proxy-manager.access.log;
        error_log /var/log/nginx/proxy-manager.error.log;

        location / {
            # Proxy Manager app
            proxy_pass http://127.0.0.1:81;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $server_name;
        }
    }
}

Save and close the file.

Step 4: Start Nginx and Nginx Proxy Manager

Start Nginx by running:

$ sudo systemctl start nginx

Wait for a few seconds, and then start Nginx Proxy Manager:

$ sudo systemctl start proxy-manager

Step 5: Accessing the Nginx Proxy Manager Web Interface

Nginx Proxy Manager web interface can be accessed at http://127.0.0.1:81 on your web browser.

Conclusion

By following the above steps, you should now have Nginx Proxy Manager installed on your NixOS machine. With Nginx Proxy Manager, you can:

  • Setup and manage reverse proxies and SSL certificates
  • Manage multiple domains
  • Monitor Nginx logs

Enjoy!