### Initiate 2FA Setup Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Starts the two-factor authentication setup process for a given user. Returns a QR code for scanning and a secret key. ```javascript const setup = await internal2FA.startSetup(access, userId); ``` -------------------------------- ### Start Development Instance Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/frontend/src/locale/README.md Clone the repository, navigate to the directory, and run the development script to start a local instance. This setup watches for file changes, especially in language files, and reloads the site automatically. ```bash git clone https://github.com/NginxProxyManager/nginx-proxy-manager.git cd nginx-proxy-manager ./scripts/start-dev -f ``` -------------------------------- ### MySQL/MariaDB Configuration Example Source: https://github.com/nginxproxymanager/nginx-proxy-manager/wiki/Installation Example JSON configuration for connecting to a MySQL or MariaDB database. ```json { "database": { "engine": "mysql", "host": "127.0.0.1", "name": "nginxproxymanager", "user": "nginxproxymanager", "password": "password123", "port": 3306 } } ``` -------------------------------- ### Start 2FA Setup for User Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Initiates the Two-Factor Authentication setup process for a user, providing a QR code and secret for the authenticator app. Requires JWT authentication. ```json { "qr": "data:image/png;base64,...", "secret": "JBSWY3DPEBLW64TMMQ======" } ``` -------------------------------- ### Source Code Organization - Initial Setup Check Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/README.md Script to perform initial setup checks for the application. ```text backend/ ├── setup.js # Initial setup check ``` -------------------------------- ### Install and Run Cypress Tests Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/test/README.md Steps to install dependencies and run the Cypress test suite locally. ```bash cd nginxproxymanager/test yarn install yarn run cypress ``` -------------------------------- ### POST /api/users/{userID}/2fa Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Start 2FA setup for a user. ```APIDOC ## POST /api/users/{userID}/2fa ### Description Start 2FA setup for a user. ### Method POST ### Endpoint /api/users/{userID}/2fa #### Path Parameters - **userID** (integer) - The ID of the user for whom to start 2FA setup #### Response ##### Success Response (200 OK) - **qr** (string) - QR code data for 2FA setup - **secret** (string) - 2FA secret key ### Response Example ```json { "qr": "data:image/png;base64,வைக்", "secret": "JBSWY3DPEBLW64TMMQ======" } ``` ``` -------------------------------- ### Signale Configuration Example Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/middleware-utilities.md An example of how to configure the signale logger via the package.json file to control date and timestamp display. ```json { "signale": { "displayDate": true, "displayTimestamp": true } } ``` -------------------------------- ### Example ConfigurationError Response Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ERRORS.md An example JSON response for a ConfigurationError, indicating an issue with the system's configuration. ```json { "error": { "code": 400, "message": "Invalid DNS provider configuration" } } ``` -------------------------------- ### UserPermission Model Usage Examples Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/database-models.md Provides examples for interacting with the UserPermission model, including creating default permissions for a new user, reading existing permissions, and updating permission levels. ```javascript import UserPermission from './models/user_permission.js'; // Create default permissions for new user await UserPermission.query().insert({ user_id: userId, visibility: 'user', proxy_hosts: 'manage', redirection_hosts: 'manage', certificates: 'manage' }); // Read const perms = await UserPermission.query() .where('user_id', userId) .first(); // Update await UserPermission.query() .patch({ visibility: 'all', proxy_hosts: 'manage' }) .where('user_id', userId); ``` -------------------------------- ### Start Docker Compose Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/docs/src/setup/index.md Command to start the services defined in your docker-compose.yml file in detached mode. ```bash docker compose up -d ``` -------------------------------- ### Portainer Example with Custom Docker Network Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/docs/src/advanced-config/index.md Example of a Portainer service configuration within a docker-compose.yml file, connected to a custom Docker network. ```yaml services: portainer: image: portainer/portainer privileged: true volumes: - './data:/data' - '/var/run/docker.sock:/var/run/docker.sock' restart: unless-stopped networks: default: external: true name: scoobydoo ``` -------------------------------- ### ProxyLocation Example Configuration Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/TYPES.md An example of a ProxyLocation object used to route requests for '/app' to a local service. It specifies the target host, port, and scheme. ```json { "path": "/app", "forward_scheme": "http", "forward_host": "localhost", "forward_port": 3001, "forward_path": "/", "advanced_config": "" } ``` -------------------------------- ### Source Code Organization - Logging Setup Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/README.md Configuration for the application's logging system. ```text backend/ ├── logger.js # Logging setup ``` -------------------------------- ### Liquid Templating Example Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/CONFIGURATION.md Demonstrates how to parse and render templates using Liquid. This is used internally for configuration generation. ```javascript const template = liquidjs.parse(templateString); const result = await template.render(data); ``` -------------------------------- ### internal2FA.startSetup Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Initiates the two-factor authentication (TOTP) setup process for a user, providing a QR code and secret for the authenticator app. ```APIDOC ## internal2FA.startSetup ### Description Initiate 2FA setup for a user. ### Method `startSetup(access, userId)` ### Parameters #### Path Parameters - **access** (Access) - Required - Access control instance - **userId** (string) - Required - The ID of the user for whom to start 2FA setup. ### Request Example ```javascript const setup = await internal2FA.startSetup(access, userId); ``` ### Response #### Success Response (JSON) - **qr** (string) - Data URL for the QR code (e.g., "data:image/png;base64,...") - **secret** (string) - The TOTP secret key (e.g., "JBSWY3DPEBLW64TMMQ======") ``` -------------------------------- ### Get Specific Setting Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Retrieves a specific system setting by its ID. ```javascript const setting = await internalSetting.get(access, { id: 'theme' }); ``` -------------------------------- ### User Model Usage Examples Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/database-models.md Demonstrates common operations for the User model: creating, reading with relations, updating, and soft deletion. ```javascript import User from './models/user.js'; // Create const user = await User.query().insertAndFetch({ email: 'user@example.com', name: 'User Name', roles: ['user'] }); // Read const user = await User.query() .where('id', userId) .withGraphFetched('permissions') .first(); // Update await User.query().patchAndFetchById(userId, { name: 'New Name', is_disabled: true }); // Delete (soft) await User.query().patchAndFetchById(userId, { is_deleted: true }); ``` -------------------------------- ### Database Transaction Example Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/middleware-utilities.md Demonstrates how to use database transactions to ensure atomicity, consistency, and isolation for multiple database operations. ```javascript import db from '../db.js'; const result = await db().transaction(async (trx) => { const user = await User.query(trx).insertAndFetch(userData); const perms = await UserPermission.query(trx).insert({ user_id: user.id, visibility: 'user' }); return { user, permissions: perms }; }); ``` -------------------------------- ### Get All Settings Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieves all settings for the Nginx Proxy Manager. Returns a list of setting objects. ```json [ { "id": "default_site_theme", "name": "Default Site Theme", "value": "light", "type": "string" } ] ``` -------------------------------- ### Docker Compose with MySQL/MariaDB Database Source: https://github.com/nginxproxymanager/nginx-proxy-manager/wiki/Installation Example docker-compose.yml to set up Nginx Proxy Manager and its database service. ```yaml version: "3" services: app: image: jc21/nginx-proxy-manager:2 restart: always ports: - 80:80 - 81:81 - 443:443 volumes: - ./config.json:/app/config/production.json - ./data:/data - ./letsencrypt:/etc/letsencrypt depends_on: - db db: image: mariadb restart: always environment: MYSQL_ROOT_PASSWORD: "password123" MYSQL_DATABASE: "nginxproxymanager" MYSQL_USER: "nginxproxymanager" MYSQL_PASSWORD: "password123" volumes: - ./data/mysql:/var/lib/mysql ``` -------------------------------- ### Get Specific Setting Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieves a specific setting by its ID. ```http GET /api/settings/{settingID} ``` -------------------------------- ### Get All Accessible Settings Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Retrieves all system settings accessible to the current user. ```javascript const settings = await internalSetting.getAll(access); ``` -------------------------------- ### GET /api/settings Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve all settings for the Nginx Proxy Manager. Returns a list of setting objects. ```APIDOC ## GET /api/settings ### Description Retrieve all settings for the Nginx Proxy Manager. Returns a list of setting objects. ### Method GET ### Endpoint /api/settings ### Response #### Success Response (200 OK) - `id` (string) - The unique identifier for the setting. - `name` (string) - The display name of the setting. - `value` (string) - The current value of the setting. - `type` (string) - The data type of the setting. ### Response Example { "example": "[\n {\n \"id\": \"default_site_theme\",\n \"name\": \"Default Site Theme\",\n \"value\": \"light\",\n \"type\": \"string\"\n }\n]" } ``` -------------------------------- ### Enable 2FA with Code Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Enables two-factor authentication for a user after verifying the provided setup code. Returns the enabled status and new backup codes. ```javascript const result = await internal2FA.enable(access, userId, '123456'); ``` -------------------------------- ### internal2FA.enable Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Enables two-factor authentication for a user after successfully verifying the provided setup code. ```APIDOC ## internal2FA.enable ### Description Enable 2FA after verifying setup code. ### Method `enable(access, userId, code)` ### Parameters #### Path Parameters - **access** (Access) - Required - Access control instance - **userId** (string) - Required - The ID of the user. - **code** (string) - Required - The 6-digit TOTP code from the authenticator app. ### Request Example ```javascript const result = await internal2FA.enable(access, userId, '123456'); ``` ### Response #### Success Response (JSON) - **enabled** (boolean) - Indicates if 2FA was successfully enabled. - **backup_codes** (string[]) - An array of generated backup codes. ``` -------------------------------- ### MySQL Database Configuration Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/CONFIGURATION.md Environment variables for configuring a MySQL database connection. Ensure these are set before starting the application. ```bash DB_MYSQL_HOST=mysql.example.com DB_MYSQL_PORT=3306 DB_MYSQL_USER=npm_user DB_MYSQL_PASSWORD=secure_password DB_MYSQL_NAME=npm_database ``` -------------------------------- ### POST /api/users Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Create a new user. Requires JWT authentication or setup mode. ```APIDOC ## POST /api/users ### Description Create a new user. Requires JWT authentication or setup mode. ### Method POST ### Endpoint /api/users #### Request Body - **email** (string) - User's email address - **name** (string) - User's name - **roles** (array of strings) - User's roles - **is_disabled** (boolean) - Whether the user is disabled - **auth** (object) - Authentication details - **type** (string) - Authentication type (e.g., "password") - **secret** (string) - Hashed password ### Request Example ```json { "email": "user@example.com", "name": "User Name", "roles": ["user"], "is_disabled": false, "auth": { "type": "password", "secret": "hashed_password" } } ``` #### Response ##### Success Response (201 Created) - **User object** ### Response Example ```json { "id": 2, "email": "user@example.com", "name": "User Name", "avatar": "https://gravatar.com/...", "roles": ["user"], "is_disabled": false, "permissions": { "visibility": "user", "proxy_hosts": "manage", "redirection_hosts": "manage", "dead_hosts": "manage", "streams": "manage", "access_lists": "manage", "certificates": "manage" } } ``` #### Errors - **400**: Validation error or duplicate email - **403**: Permission denied ``` -------------------------------- ### Start Nginx Proxy Manager Stack Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/README.md Command to bring up the Docker stack defined in your docker-compose.yml file. Use the -d flag to run in detached mode. ```bash docker compose up -d ``` -------------------------------- ### get Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Retrieves a specific proxy host configuration, with options to expand related data like certificates and ownership. ```APIDOC ## get ### Description Retrieve a specific proxy host. ### Method get(access, options) ### Parameters #### Path Parameters - **access** (Access) - Access control instance #### Request Body - **options.id** (integer) - Required - Proxy host ID - **options.expand** (string[]) - Optional - Relations to expand ### Response #### Success Response (200) - **Promise** - The requested proxy host object. ``` -------------------------------- ### Example JSON Response for AuthError Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ERRORS.md Displays a sample JSON response for an AuthError (400 Bad Request), including an optional internationalization key. ```json { "error": { "code": 400, "message": "Invalid token scope for User", "message_i18n": "error.invalid_token_scope" } } ``` -------------------------------- ### GET /api/users/{userID}/2fa Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Get 2FA status for a user. ```APIDOC ## GET /api/users/{userID}/2fa ### Description Get 2FA status for a user. ### Method GET ### Endpoint /api/users/{userID}/2fa #### Path Parameters - **userID** (integer) - The ID of the user whose 2FA status to retrieve #### Response ##### Success Response (200 OK) - **enabled** (boolean) - Whether 2FA is enabled - **pending** (boolean) - Whether 2FA setup is pending - **backup_codes_count** (integer) - Number of available backup codes ### Response Example ```json { "enabled": false, "pending": false, "backup_codes_count": 0 } ``` ``` -------------------------------- ### Get All Stream Configurations Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieves a list of all stream configurations for TCP/UDP forwarding. Supports query parameters for expansion and searching. ```json [ { "id": 1, "created_on": "2023-01-01T00:00:00.000Z", "modified_on": "2023-01-01T00:00:00.000Z", "owner_user_id": 1, "incoming_port": 3000, "forward_host": "127.0.0.1", "forward_port": 3001, "protocol": "tcp", "tcp_forwarding": true, "udp_forwarding": false, "enabled": true, "meta": {} } ] ``` -------------------------------- ### Example JSON Response for ItemNotFoundError Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ERRORS.md Shows the JSON response format for an ItemNotFoundError (404 Not Found), which may include the specific item ID. ```json { "error": { "code": 404, "message": "Not Found - proxy-host-123" } } ``` -------------------------------- ### Example CacheError Response Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ERRORS.md An example JSON response for a CacheError, indicating a failure during a cache operation. ```json { "error": { "code": 500, "message": "Internal Error" } } ``` -------------------------------- ### Logger Instances and Usage Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/middleware-utilities.md Demonstrates how to import and use different logger instances for various application events. Each logger supports standard log levels. ```javascript import { global, // Global application logger express, // HTTP request logger access, // Access control logger ssl, // SSL/certificate logger debug // Debug output logger } from '../logger.js'; global.info('Application started'); express.warn('Slow request detected'); access.error('Permission denied'); ssl.info('Certificate renewed'); debug('logger', 'Debug message'); ``` -------------------------------- ### Example ValidationError Response Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ERRORS.md An example JSON response for a ValidationError, indicating a validation failure with a specific message. ```json { "error": { "code": 400, "message": "example.com is already in use" } } ``` -------------------------------- ### Application Startup Logic Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/CONFIGURATION.md The main asynchronous function that orchestrates the application's startup sequence, including database migrations, setup checks, schema compilation, and server initialization. ```javascript async function appStart() { return migrateUp() .then(setup) .then(getCompiledSchema) .then(() => { // IP ranges fetch initialization if (!IP_RANGES_FETCH_ENABLED) { logger.info("IP Ranges fetch is disabled"); } }) .then(() => { internalCertificate.initTimer(); internalIpRanges.initTimer(); const server = app.listen(3000, () => { logger.info(`Backend PID ${process.pid} listening on port 3000`); }); }); } ``` -------------------------------- ### internalSetting.getAll Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Retrieves all system settings that are accessible to the current user. ```APIDOC ## internalSetting.getAll ### Description Retrieves all system settings that are accessible to the user based on their access level. ### Method Signature `getAll(access)` ### Parameters #### Parameters - **access** (object) - Access control information ### Returns Promise ``` -------------------------------- ### GET /api/nginx/certificates/dns-providers Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Get a list of supported DNS providers that can be used with Let's Encrypt for DNS challenge validation. ```APIDOC ## GET /api/nginx/certificates/dns-providers ### Description Get a list of supported DNS providers that can be used with Let's Encrypt for DNS challenge validation. ### Method GET ### Endpoint /api/nginx/certificates/dns-providers ### Response #### Success Response (200 OK) - **id** (string) - The identifier for the DNS provider. - **name** (string) - The display name of the DNS provider. - **credentials** (array of objects) - List of credentials required by the DNS provider. - **id** (string) - The identifier for the credential. - **name** (string) - The display name for the credential. - **required** (boolean) - Indicates if the credential is required. ### Response Example ```json [ { "id": "cloudflare", "name": "Cloudflare", "credentials": [ { "id": "api_token", "name": "API Token", "required": true } ] } ] ``` ``` -------------------------------- ### Let's Encrypt DNS Challenge Configuration Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/CONFIGURATION.md Example configuration for using a DNS challenge with Let's Encrypt, specifying the provider and credentials. Ensure DNS plugins are correctly loaded. ```json { "provider": "cloudflare", "dns_provider_credentials": { "api_token": "your_api_token" } } ``` -------------------------------- ### Get Health Status Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/README.md Retrieves the health status of the Nginx Proxy Manager API. This is a simple GET request to check if the API is running. ```APIDOC ## GET /api ### Description Retrieves the health status of the Nginx Proxy Manager API. ### Method GET ### Endpoint /api ### Response #### Success Response (200) Returns a success message if the API is healthy. ``` -------------------------------- ### Example CommandError Response (Debug Mode) Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ERRORS.md An example JSON response for a CommandError when in debug mode, including the error message, exit code, and debug information. ```json { "error": { "code": 500, "message": "Internal Error" }, "debug": { "stack": ["CommandError: nginx: [error] ..."], "previous": null } } ``` -------------------------------- ### init() Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/access-control.md Initializes the access instance by loading and validating the JWT token. This method is asynchronous and may throw errors related to authentication or permissions. ```APIDOC ## init() ### Description Initializes the access instance by loading and validating the JWT token. ### Returns Promise ### Throws - `PermissionError`: If token is missing or invalid - `AuthError`: If user cannot be loaded or token scope mismatch ### Example ```javascript try { await access.init(); console.log('Access initialized'); } catch (err) { if (err.name === 'AuthError') { console.log('Invalid token:', err.message); } } ``` ``` -------------------------------- ### GET /api/settings/{settingID} Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve a specific setting by its ID. ```APIDOC ## GET /api/settings/{settingID} ### Description Retrieve a specific setting by its ID. ### Method GET ### Endpoint /api/settings/{settingID} ### Parameters #### Path Parameters - `settingID` (string) - Required - The ID of the setting to retrieve. ### Response #### Success Response (200 OK) - Setting object ``` -------------------------------- ### Create Proxy Host with Certificate Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/README.md First, create an SSL certificate using a specified provider and domain. Then, use the obtained certificate ID to create a new proxy host configuration, enabling SSL enforcement. ```javascript // 1. Create certificate first const certRes = await fetch('http://localhost:3000/api/nginx/certificates', { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ provider: 'letsencrypt', domain_names: ['example.com'], dns_provider: 'cloudflare', dns_provider_credentials: { api_token: 'your_cloudflare_token' } }) }); const { id: certId } = await certRes.json(); // 2. Create proxy using certificate const proxyRes = await fetch('http://localhost:3000/api/nginx/proxy-hosts', { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ domain_names: ['example.com'], forward_host: '192.168.1.100', forward_port: 80, certificate_id: certId, ssl_forced: true }) }); ``` -------------------------------- ### GET /api/nginx/streams Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve all stream configurations for TCP/UDP forwarding. ```APIDOC ## GET /api/nginx/streams ### Description Retrieve all stream configurations (TCP/UDP forwarding). ### Method GET ### Endpoint /api/nginx/streams ### Parameters #### Query Parameters - **expand** (string, optional) - Comma-separated list of expansions - **query** (string, optional) - Search query ### Response #### Success Response (200 OK) - **id** (integer) - Unique identifier for the stream configuration - **created_on** (string) - Timestamp of creation - **modified_on** (string) - Timestamp of last modification - **owner_user_id** (integer) - ID of the user who owns this stream configuration - **incoming_port** (integer) - The port on which the proxy listens for incoming connections - **forward_host** (string) - The host to forward traffic to - **forward_port** (integer) - The port on which the target host listens - **protocol** (string) - The protocol used (e.g., "tcp", "udp") - **tcp_forwarding** (boolean) - Whether TCP forwarding is enabled - **udp_forwarding** (boolean) - Whether UDP forwarding is enabled - **enabled** (boolean) - Whether the stream configuration is enabled - **meta** (object) - Metadata associated with the stream configuration ### Response Example { "example": "[\n {\n \"id\": 1,\n \"created_on\": \"2023-01-01T00:00:00.000Z\",\n \"modified_on\": \"2023-01-01T00:00:00.000Z\",\n \"owner_user_id\": 1,\n \"incoming_port\": 3000,\n \"forward_host\": \"127.0.0.1\",\n \"forward_port\": 3001,\n \"protocol\": \"tcp\",\n \"tcp_forwarding\": true,\n \"udp_forwarding\": false,\n \"enabled\": true,\n \"meta\": {}\n }\n]" } ``` -------------------------------- ### GET /api/users Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve all users. Requires JWT authentication. ```APIDOC ## GET /api/users ### Description Retrieve all users. Requires JWT authentication. ### Method GET ### Endpoint /api/users #### Query Parameters - **expand** (string, optional) - Comma-separated list of related objects to expand (e.g., "permissions") - **query** (string, optional) - Search query #### Response ##### Success Response (200 OK) - **Array of user objects** ### Response Example ```json [ { "id": 1, "email": "admin@example.com", "name": "Admin User", "avatar": "https://gravatar.com/...", "roles": ["admin"], "is_disabled": false, "is_deleted": false, "created_on": "2023-01-01T00:00:00.000Z", "modified_on": "2023-01-01T00:00:00.000Z" } ] ``` ``` -------------------------------- ### create Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Creates a new proxy host configuration. This involves validating domain availability, potentially creating SSL certificates, generating Nginx configurations, and triggering an Nginx reload. ```APIDOC ## create ### Description Create a new proxy host configuration. ### Method create(access, data) ### Parameters #### Path Parameters - **access** (Access) - Access control instance #### Request Body - **data.domain_names** (string[]) - Required - Domains to proxy - **data.forward_host** (string) - Required - Backend hostname/IP - **data.forward_port** (integer) - Required - Backend port - **data.forward_scheme** (string) - Required - 'http' or 'https' - **data.certificate_id** (integer) - Optional - SSL cert ID or "new" - **data.ssl_forced** (boolean) - Optional - Force HTTPS redirect - **data.caching_enabled** (boolean) - Optional - Cache responses - **data.block_exploits** (boolean) - Optional - Exploit protection - **data.allow_websocket_upgrade** (boolean) - Optional - WebSocket support - **data.http2_support** (boolean) - Optional - HTTP/2 support - **data.locations** (ProxyLocation[]) - Optional - Path-based routing - **data.advanced_config** (string) - Optional - Custom Nginx config ### Response #### Success Response (200) - **Promise** - The created proxy host object. ### Throws - **ValidationError**: Domain already in use - **PermissionError**: Insufficient permission ``` -------------------------------- ### create Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Creates a new SSL/TLS certificate, supporting both Let's Encrypt automation and custom certificate uploads. For Let's Encrypt, it requires domain names, DNS provider details, and credentials. For custom certificates, it requires the certificate, private key, and optionally an intermediate certificate. ```APIDOC ## create(access, data) ### Description Create a new certificate (Let's Encrypt or custom). ### Parameters (Let's Encrypt) #### Path Parameters - **access** (Access) - Required - Access control instance #### Request Body - **provider** (string) - Required - 'letsencrypt' - **domain_names** (string[]) - Required - Domains to certify - **dns_provider** (string) - Required - DNS provider ID - **dns_provider_credentials** (object) - Required - Provider-specific credentials ### Parameters (Custom) #### Path Parameters - **access** (Access) - Required - Access control instance #### Request Body - **provider** (string) - Required - 'other' - **domain_names** (string[]) - Required - Domains covered - **certificate** (string) - Required - PEM certificate - **certificate_key** (string) - Required - PEM private key - **intermediate_certificate** (string) - Optional - Certificate chain ### Returns Promise ### Timeout 15 minutes for Let's Encrypt ### Throws - ValidationError: Invalid certificate or credentials - ConfigurationError: DNS provider misconfigured ``` -------------------------------- ### GET /api/nginx/certificates Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve all certificates. Supports filtering and expansion of details. ```APIDOC ## GET /api/nginx/certificates ### Description Retrieve all certificates. Supports filtering and expansion of details. ### Method GET ### Endpoint /api/nginx/certificates ### Parameters #### Query Parameters - **expand** (string, optional) - Comma-separated list of expansions - **query** (string, optional) - Search query ### Response #### Success Response (200 OK) - **id** (integer) - Certificate ID - **created_on** (string) - Creation timestamp - **modified_on** (string) - Last modification timestamp - **owner_user_id** (integer) - ID of the owner user - **name** (string) - Certificate name - **provider** (string) - Certificate provider (e.g., letsencrypt, other) - **domain_names** (array of strings) - List of domain names covered by the certificate - **expires_on** (string) - Expiration timestamp - **certificate_key** (string) - Private key of the certificate - **certificate** (string) - Public certificate content - **intermediate_certificate** (string) - Intermediate certificate content - **meta** (object) - Additional metadata ### Response Example ```json [ { "id": 1, "created_on": "2023-01-01T00:00:00.000Z", "modified_on": "2023-01-01T00:00:00.000Z", "owner_user_id": 1, "name": "example.com", "provider": "letsencrypt", "domain_names": ["example.com", "*.example.com"], "expires_on": "2025-01-01T00:00:00.000Z", "certificate_key": "-----BEGIN PRIVATE KEY-----\n...", "certificate": "-----BEGIN CERTIFICATE-----\n...", "intermediate_certificate": "", "meta": {} } ] ``` ``` -------------------------------- ### Initialize Access with Null Token Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/access-control.md Demonstrates initializing the Access class with a null token, which should result in a PermissionError. ```javascript const access = new Access(null); await access.init(); // Throws: PermissionError("Permission Denied") ``` -------------------------------- ### GET /api/nginx/streams/{streamID} Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve a specific stream configuration by its ID. ```APIDOC ## GET /api/nginx/streams/{streamID} ### Description Retrieve a specific stream configuration. ### Method GET ### Endpoint /api/nginx/streams/{streamID} ### Parameters #### Path Parameters - **streamID** (integer) - Required - The ID of the stream configuration to retrieve ### Response #### Success Response (200 OK) - Stream object ``` -------------------------------- ### GET /api/nginx/dead-hosts/{hostID} Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve a specific dead host by its ID. ```APIDOC ## GET /api/nginx/dead-hosts/{hostID} ### Description Retrieve a specific dead host. ### Method GET ### Endpoint /api/nginx/dead-hosts/{hostID} ### Parameters #### Path Parameters - **hostID** (integer) - Required - The ID of the dead host to retrieve ### Response #### Success Response (200 OK) - Dead host object ``` -------------------------------- ### GET /api/audit-log Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve all audit log entries. Supports filtering and searching. ```APIDOC ## GET /api/audit-log ### Description Retrieve all audit log entries. Supports filtering and searching. ### Method GET ### Endpoint /api/audit-log ### Parameters #### Query Parameters - `expand` (string, optional) - Comma-separated list of expansions - `query` (string, optional) - Search query ### Response #### Success Response (200 OK) - `id` (integer) - The unique identifier for the audit log entry. - `created_on` (string) - The timestamp when the entry was created. - `user_id` (integer) - The ID of the user who performed the action. - `object_id` (integer) - The ID of the object affected by the action. - `action` (string) - The type of action performed (e.g., 'created', 'deleted'). - `object_type` (string) - The type of object the action was performed on (e.g., 'proxy-host'). - `meta` (object) - Additional metadata about the action. ### Response Example { "example": "[\n {\n \"id\": 1,\n \"created_on\": \"2023-01-01T00:00:00.000Z\",\n \"user_id\": 1,\n \"object_id\": 1,\n \"action\": \"created\",\n \"object_type\": \"proxy-host\",\n \"meta\": {}\n }\n]" } ``` -------------------------------- ### GET /api/nginx/certificates/{certID} Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve details for a specific certificate using its ID. ```APIDOC ## GET /api/nginx/certificates/{certID} ### Description Retrieve details for a specific certificate using its ID. ### Method GET ### Endpoint /api/nginx/certificates/{certID} ### Parameters #### Path Parameters - **certID** (integer) - Required - The ID of the certificate to retrieve. ``` -------------------------------- ### Enable GeoIP2 Module Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/docs/src/advanced-config/index.md Enable the geoip2 module by creating a custom configuration file and including the necessary load module directives. ```nginx load_module /usr/lib/nginx/modules/ngx_http_geoip2_module.so; load_module /usr/lib/nginx/modules/ngx_stream_geoip2_module.so; ``` -------------------------------- ### GET /api/nginx/redirection-hosts/{hostID} Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve details of a specific redirection host by its ID. ```APIDOC ## GET /api/nginx/redirection-hosts/{hostID} ### Description Retrieve details of a specific redirection host by its ID. ### Method GET ### Endpoint /api/nginx/redirection-hosts/{hostID} ### Parameters #### Path Parameters - **hostID** (integer) - Required - The ID of the redirection host to retrieve ### Response #### Success Response (200 OK) - Redirection host object ``` -------------------------------- ### Create Let's Encrypt Certificate Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Use this snippet to create a new Let's Encrypt certificate. Requires domain names, DNS provider, and associated credentials. ```javascript const cert = await internalCertificate.create(access, { provider: 'letsencrypt', domain_names: ['example.com', '*.example.com'], dns_provider: 'cloudflare', dns_provider_credentials: { api_token: 'token_value' } }); ``` -------------------------------- ### NPM Auth Gateway Architecture Overview Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/docs/src/third-party/npm-auth-gateway.md Illustrates the flow of requests from a browser through NPM and the Auth Gateway to an authentication provider, and how the gateway interacts with the NPM REST API to manage access lists. ```mermaid Browser → NPM (SSL) → Auth Gateway → Auth Provider ↓ NPM REST API (:81) auto-add IP to access lists ``` -------------------------------- ### GET /api/nginx/proxy-hosts/{hostID} Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve details for a specific proxy host by its ID. ```APIDOC ## GET /api/nginx/proxy-hosts/{hostID} ### Description Retrieve details for a specific proxy host by its ID. Supports expansion of related data. ### Method GET ### Endpoint /api/nginx/proxy-hosts/{hostID} ### Parameters #### Path Parameters - `hostID` (integer) - Required - The unique identifier for the proxy host. #### Query Parameters - `expand` (string, optional) - Comma-separated list of expansions ### Response #### Success Response (200) Proxy host object (same structure as GET /api/nginx/proxy-hosts response). ``` -------------------------------- ### GET /api/schema Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieves the OpenAPI/JSON Schema definition for the Nginx Proxy Manager API. ```APIDOC ## GET /api/schema ### Description Retrieve the OpenAPI/JSON Schema definition for the API. ### Method GET ### Endpoint /api/schema ### Response #### Success Response (200 OK) - **Response** (object) - OpenAPI specification object. ``` -------------------------------- ### create Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Creates a new access list with specified authentication and IP rules. It can manage HTTP Basic Auth entries and IP-based rules, and supports options for satisfying any rule or passing through authentication. ```APIDOC ## create ### Description Create a new access list. ### Parameters #### Path Parameters - **access** (Access) - Required - Access control instance #### Request Body - **data.name** (string) - Required - Display name - **data.satisfy_any** (boolean) - Optional - Any or all rules must match - **data.pass_auth** (boolean) - Optional - Allow pass-through auth - **data.items** (AccessListAuth[]) - Optional - HTTP Basic Auth entries - **data.clients** (AccessListClient[]) - Optional - IP-based rules ### Returns Promise ### Side Effects - Creates auth and client entries - Rebuilds Nginx configs for affected hosts - Creates audit log entry ``` -------------------------------- ### GET /api/nginx/access-lists Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve all access lists. Supports filtering and expansion of related items. ```APIDOC ## GET /api/nginx/access-lists ### Description Retrieve all access lists. Supports filtering and expansion of related items. ### Method GET ### Endpoint /api/nginx/access-lists ### Parameters #### Query Parameters - **expand** (string, optional) - Comma-separated list of expansions (e.g., "items,clients") - **query** (string, optional) - Search query ### Response #### Success Response (200 OK) - **id** (integer) - The unique identifier for the access list. - **created_on** (string) - The timestamp when the access list was created. - **modified_on** (string) - The timestamp when the access list was last modified. - **owner_user_id** (integer) - The ID of the user who owns this access list. - **name** (string) - The name of the access list. - **satisfy_any** (boolean) - Whether to satisfy any of the items (OR logic). - **pass_auth** (boolean) - Whether to pass authentication for this list. - **meta** (object) - Additional metadata for the access list. - **items** (array) - A list of authentication items associated with the access list. - **clients** (array) - A list of client IP addresses or ranges allowed/denied by the access list. ### Response Example ```json [ { "id": 1, "created_on": "2023-01-01T00:00:00.000Z", "modified_on": "2023-01-01T00:00:00.000Z", "owner_user_id": 1, "name": "VPN Users", "satisfy_any": true, "pass_auth": true, "meta": {}, "items": [ { "id": 1, "access_list_id": 1, "username": "user", "password": "***" } ], "clients": [ { "id": 1, "access_list_id": 1, "address": "192.168.1.0/24", "directive": "allow" } ] } ] ``` ``` -------------------------------- ### Create Let's Encrypt Certificate Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Initiates the creation of a new Let's Encrypt certificate. Requires domain names and DNS provider details for validation. This process can take up to 15 minutes. ```json { "provider": "letsencrypt", "domain_names": ["example.com", "*.example.com"], "dns_provider": "cloudflare", "dns_provider_credentials": { "api_token": "token" } } ``` -------------------------------- ### GET /api/nginx/redirection-hosts Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Retrieve all redirection hosts. Supports filtering and expansion of related data. ```APIDOC ## GET /api/nginx/redirection-hosts ### Description Retrieve all redirection hosts. Supports filtering and expansion of related data. ### Method GET ### Endpoint /api/nginx/redirection-hosts ### Parameters #### Query Parameters - **expand** (string, optional) - Comma-separated list of expansions - **query** (string, optional) - Search query ### Response #### Success Response (200 OK) - **id** (integer) - Unique identifier for the redirection host - **created_on** (string) - Timestamp of creation - **modified_on** (string) - Timestamp of last modification - **owner_user_id** (integer) - ID of the user who owns this redirection host - **domain_names** (array of strings) - List of domain names to redirect from - **forward_domain** (string) - The domain name to forward to - **certificate_id** (integer or null) - ID of the associated SSL certificate - **ssl_forced** (boolean) - Whether SSL is forced - **caching_enabled** (boolean) - Whether caching is enabled - **block_exploits** (boolean) - Whether exploit blocking is enabled - **advanced_config** (string) - Advanced configuration options - **meta** (object) - Metadata associated with the redirection host - **enabled** (boolean) - Whether the redirection host is enabled - **preserve_path** (boolean) - Whether to preserve the URL path - **preserve_query** (boolean) - Whether to preserve the URL query parameters - **http_status** (string) - The HTTP status code for the redirection (e.g., "301") ### Response Example { "example": "[ { "id": 1, "created_on": "2023-01-01T00:00:00.000Z", "modified_on": "2023-01-01T00:00:00.000Z", "owner_user_id": 1, "domain_names": ["old.example.com"], "forward_domain": "new.example.com", "certificate_id": null, "ssl_forced": false, "caching_enabled": false, "block_exploits": false, "advanced_config": "", "meta": {}, "enabled": true, "preserve_path": false, "preserve_query": false, "http_status": "301" } ]" } ``` -------------------------------- ### Configuration Utilities Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/EXPORTED-SYMBOLS.md Provides utility functions for checking configuration settings and environment variables. ```APIDOC ## Configuration Utilities **File:** `backend/lib/config.js` **Exports:** - `isDebugMode()` - Check DEBUG env var - `isCI()` - Check CI env var - `useLetsencryptStaging()` - Check LE staging - `useLetsencryptServer()` - Get LE endpoint ``` -------------------------------- ### Get API Health Status Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/README.md Use this endpoint to check if the API is running and responsive. ```bash curl http://localhost:3000/api ``` -------------------------------- ### Initialize Access with Valid Token Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/access-control.md Shows initializing the Access class with a valid token. This snippet is used in the context of demonstrating subsequent error scenarios. ```javascript const access = new Access(tokenString); await access.init(); ``` -------------------------------- ### POST /api/nginx/dead-hosts Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/ENDPOINTS.md Create a new dead host configuration. ```APIDOC ## POST /api/nginx/dead-hosts ### Description Create a new dead host. ### Method POST ### Endpoint /api/nginx/dead-hosts ### Parameters #### Request Body - **domain_names** (array of strings) - Required - List of domain names for the dead host - **ssl_forced** (boolean) - Optional - Whether SSL is enforced - **certificate_id** (integer or null) - Optional - ID of the associated SSL certificate ### Request Example { "example": "{\n \"domain_names\": [\"dead.example.com\"],\n \"ssl_forced\": false,\n \"certificate_id\": null\n}" } ### Response #### Success Response (201 Created) - Dead host object ``` -------------------------------- ### internalSetting.get Source: https://github.com/nginxproxymanager/nginx-proxy-manager/blob/develop/_autodocs/api-reference/internal-modules.md Retrieves a specific system setting based on access level and options. ```APIDOC ## internalSetting.get ### Description Retrieves a specific system setting by its identifier, considering user access. ### Method Signature `get(access, options)` ### Parameters #### Parameters - **access** (object) - Access control information - **options** (object) - Options for retrieval, e.g., `{ id: 'theme' }` ### Returns Promise ```