Tuesday, May 9, 2017

Mautic Nginx Configuration and Setup


Just a quick example of how to setup Mautic using Nginx.

server {
listen 443;
    server_name mautic.example.com;

ssl on;
    ssl_certificate /etc/letsencrypt/live/mautic.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mautic.example.com/privkey.pem; # managed by Certbot

    access_log /var/log/nginx/mautic_access.log;
    error_log /var/log/nginx/mautic_error.log;

    client_max_body_size 50m;

    gzip on;
    gzip_proxied any;
    gzip_types       text/css text/plain text/xml application/xml application/javascript application/x-javascript text/javascript application/json text/x-json;
    gzip_vary        on;
    gzip_disable     "MSIE [1-6]\.";

    root /home/example/mautic;
    index index.php index.html index.htm;

    # redirect index.php to root
    #rewrite ^/index.php/(.*) /$1  permanent;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}