Setting up with Nginx

Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"

Top Level » CustomBuild » CustomBuild 2.0 » Nginx

Setting up with NginxLast Modified: Aug 23, 2014, 3:35 pm
Similar to the Apache version of this guide, Nginx has the ability to setup a subdomain using the templates.

In this example, we'll be setting it up for , so adjust the value on the left as desired (eg: rounducbe or any other script you have in /var/www/html)

1) You'll need to setup the server section for the webmail subdomain.  This can be accomplished by adding a 2nd server section below the domain's main one.

cd /usr/local/directadmin/data/templates
cp nginx_server.conf custom
cd custom

Edit this copied nginx_server.conf, and at the bottom of the template, below the existing server section, add this 2nd server section

       listen |IP|:|PORT_80|;

       server_name webmail.|DOMAIN|;

       root /var/www/html/squirrelmail;
       index index.php index.html index.htm;
       access_log /var/log/nginx/domains/|DOMAIN|.log;
       access_log /var/log/nginx/domains/|DOMAIN|.bytes bytes;
       error_log /var/log/nginx/domains/|DOMAIN|.error.log;

|*if HAVE_PHP1_FPM="1"|
       # use fastcgi for all php files
       location ~ \.php$
               try_files $uri =404;
               fastcgi_split_path_info ^(.+\.php)(/.+)$;
               include /etc/nginx/fastcgi_params;
               fastcgi_index index.php;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               include /etc/nginx/nginx_limits.conf;

               if (-f $request_filename)
                       fastcgi_pass unix:/usr/local/php|PHP1_RELEASE|/sockets/webapps.sock;

       location /
               # access_log off;
               proxy_set_header X-Client-IP      $remote_addr;
               proxy_set_header X-Accel-Internal /nginx_static_files;
               proxy_set_header Host             $host;
               proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       location /nginx_static_files/
               # access_log  /var/log/nginx/access_log_proxy;
               alias       /var/www/html/squirrelmail/;

       # deny access to apache .htaccess files
       location ~ /\.ht
               deny all;

Save, exit, then run:

cd /usr/local/directadmin/custombuild
./build rewrite_confs

to rewrite the User nginx.conf files.

2) You'll also need to setup the dns portition.

cd /usr/local/directadmin/data/templates
cp dns_a.conf custom
cd custom
echo "webmail=|IP|" >> dns_a.conf

This will setup the webmail A record for new dns zones.  For existing dns zones, you'll have to manually add the webmail A record to point to the domains IP.
Related Helpfiles
Setting up as default for new domains.
Setting up with nginx/apache proxy

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST