Nginx Management
Pigsty installs Nginx on INFRA nodes as the entry point for all web services, listening on standard ports 80/443.
In Pigsty, you can configure Nginx to provide various services through inventory:
- Expose web interfaces for monitoring components like Grafana, VictoriaMetrics (VMUI), Alertmanager, and VictoriaLogs
- Serve static files (software repos, documentation sites, websites, etc.)
- Proxy custom application services (internal apps, database management UIs, Docker application interfaces, etc.)
- Automatically issue self-signed HTTPS certificates, or use Certbot to obtain free Let’s Encrypt certificates
- Expose services through a single port using different subdomains for unified access
Basic Configuration
Customize Nginx behavior via infra_portal parameter:
infra_portal is a dictionary where each key defines a service and the value is the service configuration.
Only services with a domain defined will generate corresponding Nginx config files.
home: Special default server for homepage and built-in monitoring component reverse proxies- Proxy services: Specify upstream service address via
endpointfor reverse proxy - Static services: Specify local directory via
pathfor static file serving
Server Parameters
Basic Parameters
| Parameter | Description |
|---|---|
domain | Optional proxy domain |
endpoint | Upstream service address (IP:PORT or socket) |
path | Local directory for static content |
scheme | Protocol type (http/https), default http |
domains | Additional domain list (aliases) |
SSL/TLS Options
| Parameter | Description |
|---|---|
certbot | Enable Let’s Encrypt cert management, value is cert name |
cert | Custom certificate file path |
key | Custom private key file path |
enforce_https | Force HTTPS redirect (301) |
Advanced Settings
| Parameter | Description |
|---|---|
config | Custom Nginx config snippet |
index | Enable directory listing (for static) |
log | Custom log file name |
websocket | Enable WebSocket support |
auth | Enable Basic Auth |
realm | Basic Auth prompt message |
Configuration Examples
Reverse Proxy Services
Static Files and Directory Listing
Custom SSL Certificate
Using Let’s Encrypt Certificates
Force HTTPS Redirect
Custom Config Snippet
Management Commands
Domain Resolution
Three ways to resolve domains to Pigsty servers:
- Public domains: Configure via DNS provider
- Internal DNS server: Configure internal DNS resolution
- Local hosts file: Modify
/etc/hosts
For local development, add to /etc/hosts:
Pigsty includes dnsmasq service, configurable via dns_records parameter for internal DNS resolution.
HTTPS Configuration
Configure HTTPS via nginx_sslmode parameter:
| Mode | Description |
|---|---|
disable | Listen HTTP only (nginx_port) |
enable | Also listen HTTPS (nginx_ssl_port), default self-signed cert |
enforce | Force redirect to HTTPS, all port 80 requests get 301 redirect |
For self-signed certificates, several access options:
- Trust the self-signed CA in browser (download at
http://<ip>/ca.crt) - Use browser security bypass (type “thisisunsafe” in Chrome)
- Configure proper CA-signed certs or Let’s Encrypt for production
Certbot Certificates
Pigsty supports using Certbot to request free Let’s Encrypt certificates.
Enable Certbot
- Add
certbotparameter to services ininfra_portal, specifying cert name - Configure
certbot_emailwith a valid email - Set
certbot_signtotruefor auto-signing during deployment
Manual Certificate Signing
Or run the scripts directly on the server:
For more info, see Certbot: Request and Renew HTTPS Certificates
Default Homepage
Pigsty’s default home server provides these built-in routes:
| Path | Description |
|---|---|
/ | Homepage navigation |
/ui/ | Grafana monitoring dashboards |
/vmetrics/ | VictoriaMetrics VMUI |
/vlogs/ | VictoriaLogs log query |
/vtraces/ | VictoriaTraces tracing |
/vmalert/ | VMAlert alerting rules |
/alertmgr/ | AlertManager alert management |
/blackbox/ | Blackbox Exporter |
/pev | PostgreSQL Explain visualization |
/haproxy/<cluster>/ | HAProxy admin interface (if any) |
These routes allow accessing all monitoring components through a single entry point, no need for multiple domain configurations.
Best Practices
- Use domain names instead of IP:PORT for service access
- Properly configure DNS resolution or hosts file
- Enable WebSocket for real-time apps (e.g., Grafana, Jupyter)
- Enable HTTPS for production
- Use meaningful subdomains to organize services
- Monitor Let’s Encrypt certificate expiration
- Use
configparameter for custom Nginx configurations
Full Example
Here’s the Nginx configuration used by Pigsty’s public demo site demo.pigsty.io:
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)