1

I have cPanel and Apache 2.4 on my CentOS 6.6 VPS. I installed Nginx as a reverse proxy.

Everything works fine. I have 2 domains on the VPS & I'm able to configure them both on nginx.

The problem is that I must edit the configuration and reload nginx every time a domain is added.

This is part of my nginx.conf file:

http {
...

 map $host $root {
      hostnames;
      default /var/www;
      example1.com /home/username1/public_html;
      www.example1.com /home/username1/public_html;
      example2.com /home/username2/public_html;
      www.example2.com /home/username2/public_html;
   }

server {
   listen 127.0.0.1:80 default_server;
   root $root;
   server_name server1;
   access_log off;
   error_log off;  
   location ~*  \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css)$ {
   expires 30d;
}

As you can see, this code: example1.com /home/username1/public_html; which defines the first domain/account on the server. What I'm trying to achieve is to place a code like the following: $domain /home/$user/public_html;in order to dynamically read any domain will be added without editing the configuration for specific domains, as well as the username directories. Actually, I tried this code but it didn't work.

Maybe I can declare some variables and make this work as I want? If anyone here have suggestions or can edit my code, that would be great. Thank you.

Note: I don't want to use NginxCP plugin for cPanel because it installs mod_rpaf module which is not working on Apache 2.4 and has been replaced by mod_remoteip.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.