How to Enable Wildcard Domain Vhost in Nginx and Apache – CWP/Centos

In this tutorial we’ll learn and create wildcard vhost for Nginx and Apache under CWP Control web panel. I’ve created wildcard templates for this two webservers as a proxy for nginx which is in-front of Apache i.e. Apache is still the main backend webserver.

Wildcard vhosts is useful in situation like when you’re using WP Multisite like application or your own multisite CMS.

Before you start and use this wildcard templates ensure you’ve wildcard DNS is setup i.e. *.mysterydata.com. here “*” is the wildcard DNS Name. eg. :

I’ve added this nginx wildcard proxy templates they are listed below :

wildcard-force-https-http2.stpl  wildcard-force-https.stpl  wildcard-http2.stpl  wildcard.stpl
wildcard-force-https-http2.tpl   wildcard-force-https.tpl   wildcard-http2.tpl   wildcard.tpl

and Apache wildcard template with php-cgi and php-fpm

Now lets get this templates downloaded to your server

Step 1 :

cd /usr/local/cwpsrv/htdocs/resources/conf/web_servers/
wget https://blog.alphagnu.com/upload/cwp-wildcard-templates.zip
unzip cwp-wildcard-templates.zip

Done wildcard templates are downloaded to the template location.

Step 2 :

Setup domain to use wildcard configuration and template :

Navigate to CWP.admin >> Webservers Settings >>> Webservers Domain conf >>>> Choose User  from drop down and domain name and hit Create Configuration button

  • Now select Webserver combination i.e. nginx + apache + php-fpm/php-cgi or nginx + varnish + apache + php-fpm/php-cgi *** if you didn’t installed nginx then you only need to select for Apache.
  • Next choose wildcard template listed in dropdown under option “Nginx default vhost template” and “Apache default vhost template
  • Choose desired php verison and Check the boxRebuild WebServers conf for domain on save” then click “Save changes

That’s it you’ve configured wildcard domain/subdomain under cwp panel.

Back to top button