npm package: @pdkkid/n8n-nodes-nginx-proxy-manager
Description: N8N nodes for Nginx Proxy Manager API integration
Author: Pdkkid
Latest version: 1.0.7

# Nginx Proxy Manager - N8N Integration

This package provides N8N nodes for interacting with the Nginx Proxy Manager API, allowing you to automate proxy host management, user administration, and system monitoring directly from N8N workflows.

## Features

- **Proxy Host Management**: Create, read, update, and delete proxy hosts
- **User Management**: Manage users, permissions, and authentication
- **Settings Management**: Get and update system settings
- **Health Monitoring**: Check API health status
- **Reporting**: Get statistics about hosted services
- **Token Management**: Automatic token handling with refresh support

## Installation

1. Copy this directory to your N8N custom nodes folder:
   ```bash
   cp -r n8n-nodes-nginx-proxy-manager ~/.n8n/nodes/
   ```

2. Rebuild N8N:
   ```bash
   npm rebuild
   ```

3. Restart N8N

## Setup

### 1. Add Credentials

1. In N8N, go to **Credentials**
2. Click **New** and select **Nginx Proxy Manager API**
3. Fill in the following:
   - **API URL**: Your Nginx Proxy Manager API base URL
   - **Email**: Your NPM login email
   - **Password**: Your NPM login password
   - **Access Token** (optional): If you already have a valid token, paste it here to skip credential-based auth

### 2. Use in Workflows

Add the "Nginx Proxy Manager" node to any workflow and select from the available operations.

## Available Operations

### Health
- **Get Status**: Check if the API is healthy

### Proxy Hosts
- **Get All**: Retrieve all proxy hosts (supports expansion of related data)
- **Get**: Retrieve a specific proxy host by ID
- **Create**: Create a new proxy host
- **Update**: Update an existing proxy host
- **Delete**: Delete a proxy host

**Proxy Host Fields:**
- Domain Names (required)
- Forward Host (required) - IP or hostname
- Forward Port (required)
- Forward Scheme - HTTP or HTTPS
- SSL Forced
- Caching Enabled
- Block Exploits
- Allow Websocket Upgrade
- HTTP/2 Support
- HSTS Enabled
- HSTS Subdomains
- Advanced Nginx Config

### Users
- **Get All**: Retrieve all users (with optional permissions expansion)
- **Get**: Get a specific user
- **Create**: Create a new user
- **Update**: Update user details
- **Delete**: Delete a user
- **Update Auth**: Change user password
- **Update Permissions**: Set user permissions for different resources

**Permission Levels:**
- `hidden` - User cannot see the resource
- `view` - User can view but not modify
- `manage` - User has full control

**Visibility Levels:**
- `all` - User can see all items
- `user` - User can only see their own items

### Settings
- **Get All**: Retrieve all system settings
- **Get**: Get a specific setting
- **Update**: Update a setting value

**Common Settings:**
- `default-site` - What to show for unknown hosts

### Reports
- **Get Hosts Report**: Get statistics about proxy hosts, redirections, streams, and dead hosts

### Tokens
- **Get New Token**: Request a new access token from credentials
- **Refresh Token**: Refresh an existing token

## Examples

### Create a Proxy Host

```json
{
  "resource": "proxyHost",
  "operation": "create",
  "domainNames": "example.com,www.example.com",
  "forwardHost": "192.168.1.100",
  "forwardPort": 8080,
  "forwardScheme": "http",
  "enabled": true,
  "sslForced": false,
  "blockExploits": true
}
```

### Get All Proxy Hosts with Details

```json
{
  "resource": "proxyHost",
  "operation": "getAll",
  "expand": "owner"
}
```

### Create a New User

```json
{
  "resource": "user",
  "operation": "create",
  "email": "newuser@example.com",
  "name": "New User",
  "nickname": "New",
  "roles": ["user"]
}
```

### Update User Permissions

```json
{
  "resource": "user",
  "operation": "updatePermissions",
  "userId": 2,
  "visibility": "all",
  "proxyHostsPermission": "manage"
}
```

### Check System Health

```json
{
  "resource": "health",
  "operation": "getStatus"
}
```

### Get Statistics

```json
{
  "resource": "report",
  "operation": "getHostsReport"
}
```

## API Expansion Options

Some operations support expanding related data:

- `access_list` - Include access list information
- `owner` - Include owner/user information
- `certificate` - Include SSL certificate information
- `permissions` - Include user permission details

## Error Handling

The nodes will return detailed error messages from the API. Common errors include:

- **401 Unauthorized**: Invalid credentials or expired token
- **404 Not Found**: Resource doesn't exist
- **400 Bad Request**: Invalid parameters
- **409 Conflict**: Resource conflict (e.g., duplicate domain)

## Rate Limiting

The Nginx Proxy Manager API doesn't have explicit rate limits, but it's recommended to add delays between requests if making bulk operations.

## Troubleshooting

### "No credentials provided"
Make sure you've added the Nginx Proxy Manager API credentials and selected them in the node.

### "401 Unauthorized"
Verify your email and password are correct. The token may have expired - try refreshing or re-authenticating.

### "Domain already in use"
The domain name is already configured for another proxy host. Remove it from the existing host first.

### "Nginx configuration error"
Check your advanced configuration syntax. Invalid Nginx directives will prevent the host from being enabled.

## Support

For issues with the integration, check:
- The [Nginx Proxy Manager documentation](https://nginxproxymanager.com/)
- The [API Schema](https://github.com/NginxProxyManager/nginx-proxy-manager)

## License

MIT

## Changelog

### v1.0.0
- Initial release
- Full support for proxy hosts, users, settings, and tokens
- Health monitoring and reporting endpoints