OPNsense (Docker Proxy)
Proxy to OPNsense API for monitoring.
Overview
NGINX is a high-performance web server and reverse proxy server originally developed by Igor Sysoev in 2004 to solve the C10K problem of handling ten thousand concurrent connections. Its event-driven, asynchronous architecture makes it exceptionally efficient at handling multiple connections with minimal resource consumption, establishing it as the backbone of many high-traffic websites and critical infrastructure components worldwide.
This OPNsense proxy configuration leverages NGINX's reverse proxy capabilities to create a secure intermediary layer between external monitoring tools and your OPNsense firewall's API endpoints. OPNsense, being a FreeBSD-based firewall solution, exposes REST API endpoints for system monitoring and configuration, but direct access often requires complex authentication handling and poses security concerns. NGINX acts as an intelligent proxy, handling authentication, request routing, and connection management while providing additional layers of security through rate limiting and access controls.
Network administrators and homelab enthusiasts managing OPNsense firewalls will find this proxy invaluable for integrating firewall metrics into monitoring dashboards like Grafana, centralized logging systems, or custom automation scripts. The proxy eliminates the complexity of handling OPNsense's API authentication in multiple applications while providing a standardized HTTP interface that monitoring tools can easily consume, making firewall observability significantly more accessible.
Key Features
- Event-driven asynchronous architecture handling thousands of concurrent API connections with minimal memory overhead
- Advanced upstream health checking and automatic failover for OPNsense API endpoint availability
- Built-in rate limiting and connection throttling to protect OPNsense from API abuse
- SSL/TLS termination with configurable cipher suites for encrypted API communications
- Request buffering and response caching to reduce load on OPNsense hardware
- Detailed access logging with customizable log formats for API usage analytics
- WebSocket proxying support for real-time OPNsense monitoring applications
- Geographic and IP-based access controls for API security hardening
Common Use Cases
- 1Grafana dashboard integration for real-time OPNsense firewall metrics and performance monitoring
- 2Centralized SIEM integration collecting OPNsense logs and security events through API endpoints
- 3Multi-tenant environments where different teams need controlled access to specific OPNsense API functions
- 4Homelab monitoring stacks requiring consolidated network device metrics alongside server infrastructure
- 5Automated network configuration management systems updating OPNsense rules and policies via API
- 6Load balancing API requests across multiple OPNsense instances in high-availability setups
- 7Development environments testing OPNsense integrations without exposing production firewall APIs
Prerequisites
- OPNsense firewall with API access enabled in System > Access > Users configuration panel
- Valid OPNsense API key and secret pair generated for authentication to API endpoints
- Minimum 256MB RAM allocated to NGINX container for optimal proxy performance under load
- Network connectivity between Docker host and OPNsense management interface on required ports
- Understanding of NGINX configuration syntax for customizing proxy behaviors and security policies
- Port 8080 available on Docker host for external access to the OPNsense proxy service
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 opnsense-proxy: 3 image: nginx:alpine4 container_name: opnsense-proxy5 restart: unless-stopped6 volumes: 7 - ./nginx.conf:/etc/nginx/nginx.conf:ro8 ports: 9 - "8080:80".env Template
.env
1# Configure nginx.conf for OPNsense APIUsage Notes
- 1Docs: https://docs.opnsense.org/development/api.html
- 2Configure nginx.conf to proxy requests to OPNsense API
- 3Enable API access in OPNsense: System > Access > Users
- 4Create API key+secret for authentication
- 5Use for Grafana dashboards, monitoring integrations
- 6OPNsense itself runs on dedicated hardware, not Docker
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 opnsense-proxy:5 image: nginx:alpine6 container_name: opnsense-proxy7 restart: unless-stopped8 volumes:9 - ./nginx.conf:/etc/nginx/nginx.conf:ro10 ports:11 - "8080:80"12EOF1314# 2. Create the .env file15cat > .env << 'EOF'16# Configure nginx.conf for OPNsense API17EOF1819# 3. Start the services20docker compose up -d2122# 4. View logs23docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/opnsense/run | bashTroubleshooting
- 502 Bad Gateway errors: Verify OPNsense management interface is accessible and API endpoints are responding correctly
- Authentication failures in proxy logs: Check OPNsense API key/secret configuration and ensure they're properly encoded in NGINX upstream directives
- High memory usage in NGINX container: Reduce proxy_buffering settings or increase worker_rlimit_nofile for better connection handling
- SSL certificate errors when connecting to OPNsense: Configure proxy_ssl_verify off in NGINX upstream block for self-signed certificates
- Rate limiting blocking legitimate requests: Adjust limit_req_zone parameters in NGINX configuration to match expected API usage patterns
- Container fails to start with permission denied: Ensure nginx.conf file has proper read permissions and valid syntax using nginx -t command
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Ad Space
Shortcuts: C CopyF FavoriteD Download