Nginx server basic configuration for AppMail

Nginx server basic configuration for AppMail

Please note that the below configuration is going to use php-fpm for what is worth.

/etc/nginx/nginx.conf
# For more information on configuration, see:
#   * Official English Documentation: https://nginx.org/en/docs/
#   * Official Russian Documentation: https://nginx.org/ru/docs/

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See https://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    index   index.html index.htm;

    #root /usr/share/nginx/html;

  # this is the section that matters for AppMail.
    server {
     listen      80;
     server_name domain.com;
     root        /usr/share/nginx/html;

     location / {
         if (!-e $request_filename){
             rewrite ^(/)?api/.*$ /api/index.php;
         }
         if (!-e $request_filename){
             rewrite ^(/)?customer/.*$ /customer/index.php;
         }
         if (!-e $request_filename){
             rewrite ^(/)?backend/.*$ /backend/index.php;
         }
         if (!-e $request_filename){
             rewrite ^(.*)$ /index.php;
         }
         index  index.html index.htm index.php;
     }

     #error_page  404              /404.html;

     # redirect server error pages to the static page /50x.html
     #
     error_page   500 502 503 504  /50x.html;

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
     #
     location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_read_timeout 600s;
        fastcgi_send_timeout 600s;
    }

     # deny access to .htaccess files, if Apache's document root
     # concurs with nginx's one
     #
     location ~ /\.ht {
         deny  all;
     }
   }
}
    • Related Articles

    • Guide to follow while creating your AppMail extensions

      The naming convention of the extension folder and extension init file for the extension remains the same, if your extension folder is called amazon-s3 your extension init file must be called AmazonS3Ext.php and must contain the class AmazonS3Ext ...
    • Add a new delivery server type

      If you look in apps/common/models/ you will see lots of files called DeliveryServer{TYPE}.php where type is the provider they implement, for example DeliveryServerAmazonSesWebApi.php In order to create your own delivery server implementation, you ...
    • Upgrading notes for AppMail 1.x to AppMail 2.x

      When upgrading from AppMail 1.x to AppMail 2.x there are a few things you need to do before starting the upgrade process. #1. It is very important you backup your application, be it on your own or by using the Backup Manager. #2. You need to disable ...
    • Extend AppMail

      AppMail is highly extensible and flexible. You can extend it using a high number of extensions for payments, backup, email validation and so on, you can alter the look of it by either using customisations or custom themes and you can translate it in ...
    • What folders have to be writable by the web server?

      Note: we use 0777 for permissions because this is what works on most hosting accounts. The data that you create in the web interface has to also be available in the command line as well and vice-versa, and often the user/group under which the web ...