Nginx server basic configuration for mailwizz

twisted1919

Administrator
Staff member
Here is a sample of how your nginx configuration should look like in order to make mailwizz work properly.
Please note that the above configuration is going to use php-fpm for what is worth.

/etc/nginx/nginx.conf file:
Code:
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://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 http://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 mailwizz.
    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$ {
         fastcgi_split_path_info  ^(.+\.php)(.*)$;

         fastcgi_param  PATH_INFO        $fastcgi_path_info;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include fastcgi_params;

         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;

         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;
     }
   }
}
 
If you set VPS running VestaCP in conjunction nginx + php-fpm
for your domain that will run Mailwizz /home/your_name/conf/web/nginx.conf
file should look like this:
Code:
server {
    listen      000.000.000.000:80;
    server_name your_domain.com www.your_domain.com;
    root        /home/your_name/web/your_domain.com/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/your_domain.com.log combined;
    access_log  /var/log/nginx/domains/your_domain.com.bytes bytes;
    error_log   /var/log/nginx/domains/your_domain.com.error.log error;

    location / {

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#            if (!-f $document_root$fastcgi_script_name) {
#                return  404;
#            }

            fastcgi_pass    127.0.0.1:9002;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   /home/your_name/web/your_domain.com/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/your_name/conf/web/nginx.your_domain.com.conf*;
}
 
Last edited:
@Celso Max - It should be no difference if you install it in a subdomain or domain, the only difference would be your server name directive in the nginx configuration, that's all.
I suggest you look in the nginx server logs ;)
 
Actually now i am getting "502 Bad Gateway" nginx error...........when click on "view details" button of Latest open, Click rate, Open rate in Campaign overview
 
Back
Top