bench setup nginx command generates an NGINX configuration file for serving your Frappe sites.
Usage
Options
NGINX access log configuration.Choices:
none: Disable access loggingsite: Separate log file per sitecombined: Single combined log file for all sites
Specify the log format for NGINX access logs.Use
none or empty string to not set a value.Only applies when --logging is not none.Automatically overwrite existing
nginx.conf without confirmation.Examples
Basic Configuration
Generate NGINX configuration with defaults:Disable Logging
Generate configuration without access logs:Per-Site Logging
Create separate log files for each site:Custom Log Format
Use a custom NGINX log format:Skip Confirmation
Overwrite existing configuration without prompting:Generated Configuration
File Location
Configuration Structure
The generated NGINX configuration includes:- Upstream blocks: For Frappe web and socketio servers
- Server blocks: For each site
- Rate limiting: If enabled in bench config
- SSL configuration: If SSL certificates are configured
- Static file serving: For assets
- Proxy settings: For dynamic requests
Configuration Types
Port-Based (Default)
Whendns_multitenant is false, each site gets its own port:
DNS-Based (Multi-Tenant)
Whendns_multitenant is true, all sites use port 80/443:
Production Setup
Create Symlink
Test Configuration
Always test before reloading:Reload NGINX
Apply the new configuration:Rate Limiting
Enable rate limiting incommon_site_config.json:
SSL Configuration
The NGINX configuration automatically includes SSL settings if certificates are configured:Logging
Log Locations
Combined logging (default):View Logs
Advanced Configuration
Custom Timeout
Set HTTP timeout incommon_site_config.json:
Custom Ports
Change webserver and socketio ports:Wildcard SSL
For wildcard SSL certificates:Troubleshooting
Port Conflicts
If you see “Port already in use” errors:Configuration Test Failed
Ifnginx -t fails:
Sites Not Accessible
-
Verify NGINX is running:
-
Check bench processes:
-
Test upstream connection:
-
Check firewall:
When to Regenerate
Regenerate NGINX configuration after:- Adding or removing sites
- Changing site domains
- Adding SSL certificates
- Modifying timeout settings
- Changing ports
- Enabling/disabling rate limiting
Related Commands
bench setup production- Complete production setupbench setup reload-nginx- Test and reload NGINXbench setup lets-encrypt- Add SSL certificatesbench config- Modify bench configuration
Source Code
Implementation:bench/config/nginx.py:17
Command definition: bench/commands/setup.py:28