Connect with us

Wordpress Tips

How to Change Default Vhost Config Template for Nginx?

Here is a problem that we encountered when trying to update our Nginx software: the update was simply overwriting our custom Nginx rules, many of which were created to stop folks from messing with our sites. We use cPanel to manage our domains but were manually updating vhost config files for our domains. Updating them over and over again when you have a couple of sites is not tough. But if you have more than a dozen of sites, the process becomes time-consuming. You just have to find the “createvhosts.py” files to address the issue.

Tip: 20 ways to drive more traffic to your site

nginx

In our case, the file is located in our scripts directory (scripts/createvhosts.py). Those of you who know your Nginx are going to find the file pretty easy to read. As you can see in the above example, there is no need to hard-code your IP (“%s” takes care of that). Things are a bit different for those of you who want tn ban certain IPs from accessing specific files and directories on your site.

nginx admin

Before making changes to your files, make sure you back them up. When you are done, you can rebuild your vhosts by going to: WHM -> Plugins -> Nginx Admin -> Rebuild Vhosts. Needless to say, you can build very sophisticated templates with this approach, but you have to know what you are doing.

Continue Reading
You may want to check out:
*some of our articles and lists might include aff links to fund our operations. Please read our disclaimer on how we fund Exxponent.
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

More in Wordpress Tips

To Top