Nginx and Apache Virtual Host Configuration Files Setup - Plesk Tips

Setting Up Nginx and Apache Virtual Host Configuration Files

Plesk Onyx for Linux utilizes Apache web server for website hosting. By default it is strengthen with Nginx to achieve higher level of performance.
Apache web server is not directly operating hosted websites – it managed virtual hosts instead. Virtual hosts are web resources with assigned host or IP.
As soon as the administrator creates a site under Plesk, system adds new virtual host to Apache.

The configuration settings for each virtual host are stored in configuration files which you’ll find in the /var/www/vhosts/system/<domain_name>/conf/ directory. The ones you’re looking for are:

  • <version>_httpd.conf – Apache virtual host configuration
  • <version>_nginx.conf – Nginx configuration

The final Apache virtual host configuration will include all httpd.conf and nginx.conf files from all virtual hosts.

Plesk always remembers how it was set up before, because all previous configuration states are recorded in a virtual host configuration file. This means that administrators and domain owners can check out what was changed and when. You can find details of current file states here – last_httpd.conf and last_nginx.conf.

Every time you make a change to a virtual hosting configuration, say you change the hosting type for a domain, the system re-generates the configuration files. So, if you edit the httpd.conf and nginx.conf files yourself, the changes you make will be lost after you change the virtual host settings in the Plesk UI. To prevent this, extra files are used to outline custom configuration for domains:

  • vhost.conf and vhost_ssl.conf – custom Apache directives for two situations: when clients access the site over HTTP and HTTPS respectively. These files are added to the httpd.conf.
  • vhost_nginx.conf – custom nginx directives. This file is included in the nginx.conf.

The files with custom per-domain configuration are stored in the /var/www/vhosts/system/<domain_name>/conf/ directory.

A lot of the settings in these files take precedence over the server-wide configuration of a virtual host (httpd.conf and nginx.conf). For instance, if you include directives that are already in the site’s current httpd.conf file, the system will use your values from the vhost.conf and vhost_ssl.conf files.

Editing Virtual Host Configuration Files

When you want to edit virtual host configuration files, you have a couple of choices:

Manually – you can add custom directives to the following files from /var/www/vhosts/system/<domain_name>/conf/ directory:

  • vhost.conf and vhost_ssl.conf
  • vhost_nginx.conf

Using Plesk GUI – Go to Websites & Domains > select a website > Web Server Settings tab you can specify:

  • Common Apache settings. Most commonly used directives (like MIME types or index files). These directives will be included in httpd.conf.
  • nginx settings. Directives that define the scope of nginx’s role in serving different types of website content (static and dynamic).
  • Additional Apache directives. You can add several custom Apache directives at once in the Additional directives for HTTP and Additional directives for HTTPS fields. These fields correspond to vhost.conf and vhost_ssl.conf files respectively.
  • Additional nginx directives. You can add several custom nginx directives at once in the Additional nginx directives field. This field corresponds to vhost_nginx.conf file.

The changes you made in the web server configuration will be applied automatically.

NB! You may have just upgraded from the older Plesk version. If you did and you are now configuring the vhost.conf and vhost_ssl.conf files,  you’ll need to use the httpdmng utility to apply the changes from your configuration files. For example, to generate web server configuration files for a website, run the command: /usr/local/psa/admin/sbin/httpdmng –reconfigure-domain <domain_name>

How useful was this post?

Click on a heart to rate it!

Average rating / 5. Vote count:

Oh no, sorry about that!

Let us know how we can do better below


Elvis Plesky
Our fun and curious team mascot's always plugged into the latest trends. He's here to share his knowledge and help you solve your tech problems.
Showing 2 comments
  • Avatar

    Can I do the load balancer for my Nginx throught this virtual host nginx conf?

Leave a Comment

Start typing and press Enter to search