Please wait...

Nginx server basic configuration for MailWizz

If you need a very advanced/optimised nginx configuration, you’ll find one here, otherwise below sample should do it for the simplest use cases.

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

# For more information on configuration, see:
#   * Official English Documentation:
#   * Official Russian Documentation:

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/;

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
    # 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;
     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
     location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        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;