Nginx Vhost Config Generator
Generate Centmin Mod Nginx virtual host configuration files for your domain.
Creating Multiple Nginx Vhosts
To create Nginx vhosts (virtual hosts) for your domains, use the nv command or centmin.sh menu option 2. For production sites, use Let's Encrypt SSL (recommended). Run the command once per domain:
# Recommended: Create vhost with Let's Encrypt production SSL
nv -d domain1.com -s lelived
nv -d domain2.com -s lelived
nv -d domain3.com -s lelived
# Testing only: Create vhost with self-signed SSL
nv -d testdomain.com -s y
Each command creates the Nginx vhost config at /usr/local/nginx/conf/conf.d/yourdomain.com.conf and the web root at /home/nginx/domains/yourdomain.com/public. Use the generator below to preview the configuration before creating your vhosts.
About This Tool
Centmin Mod Nginx server uses a specific vhost structure different from other Nginx web servers. The centmin.sh menu option 2 auto-generates the domain's Nginx vhost conf file. This tool generates reference copies of those default vhost configurations with your domain name substituted in.
This tool generates reference config files only. SSL certificate files (dhparam.pem, .crt, .key) are NOT generated. Use centmin.sh menu option 2 on your server to create vhosts with all necessary files, or follow the manual SSL setup guide.
You Entered
- Domain Name:
- SSL Mode:
- Vhost Type:
Equivalent CLI Command
Run this on your server instead of using this generator:
Pre-requisite Configuration
Requires LETSENCRYPT_DETECT='y' in /etc/centminmod/custom_config.inc. See Let's Encrypt guide.
Staging certificates are NOT browser-trusted. Use for testing before issuing production certs with lelive or lelived.
HTTPS default mode: HTTP requests are automatically redirected to HTTPS. Only the .ssl.conf vhost file is created.
SSL Certificate Setup
Nginx Vhost Configuration
SSL Vhost Configuration
Notes
Enter a domain name and click Generate
Your nginx vhost configuration will appear here.
Change a Domain Name with HTTPS and Let's Encrypt
If you need to rename a domain on your Centmin Mod server while preserving its SSL certificates and web content, follow these steps. This process copies the existing vhost configuration and SSL files to the new domain name, then reissues the SSL certificate.
Make sure DNS for the new domain is already pointing to your server before reissuing SSL certificates.
-
Copy the SSL certificate directory from the old domain to the new domain:
cp -a /usr/local/nginx/conf/ssl/olddomain.com /usr/local/nginx/conf/ssl/newdomain.com -
Copy the vhost configuration file:
cp /usr/local/nginx/conf/conf.d/olddomain.com.ssl.conf /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf -
Replace the old domain name with the new domain inside the copied config:
sed -i 's/olddomain.com/newdomain.com/g' /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf -
Copy or move the web root directory:
cp -a /home/nginx/domains/olddomain.com/ /home/nginx/domains/newdomain.com/ -
Clean up the old vhost config (optional):
rm /usr/local/nginx/conf/conf.d/olddomain.com.ssl.conf -
Reissue the SSL certificate for the new domain using acmetool, then test and restart Nginx:
acmetool.sh reissue-only newdomain.com live nginx -t && ngrestart
For more details, see the forum discussion.
Customize Nginx Vhost Templates
Centmin Mod generates Nginx vhost configuration files from internal templates. If you need to customize the default vhost structure, the template files are located at:
inc/nginx_addvhost.inc— used bycentmin.shmenu option 2 and menu option 22tools/nv.sh— used by thenvcommand shortcut
These templates use conditional shell variables that must be preserved when making edits:
${DEDI_IP}— the dedicated IP address for the vhost${vhostname}— the domain name being created$LISTENOPT— listen directive options
Native Nginx $ variables must be backslash-escaped in the templates (e.g., \$request_uri, \$host) so the shell does not interpret them during vhost creation.
Do not remove or rename the shell variables like ${DEDI_IP}, ${vhostname}, or $LISTENOPT — they are required for the vhost creation process to work correctly.
Customizations made directly to these template files will be overwritten when you run cmupdate. For persistent changes, use hooks or override files if available.
For more details, see the forum discussion.