LoginSignup
0
1

More than 3 years have passed since last update.

Nginx で Mautic を使うための config

Last updated at Posted at 2017-06-14

Nginx で Mautic を使うための Config 設定です。
location 内の設定のみですので、その他のチューニングはお願いします。

  • Amazon Linux 2 & Nginx + PHP7.2 で動作確認をしました (2019年3月)
  • パスは /var/www/EXAMPLE.COM を変えてください
  • server_name EXAMPLE.COM; を適宜変えて下さい
  • ログの保存先を適宜変えてください。
  • 適宜 SSL 証明書の設定を追加して下さい。
/etc/nginx/conf.d/10_vhosts_example.com.conf
server {
    listen       80;
    listen       [::]:80;
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;

    server_name  EXAMPLE.COM;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";

    charset      utf-8;
    client_max_body_size 32m;

    access_log   /var/log/nginx/EXAMPLE.COM-access.log main;
    error_log    /var/log/nginx/EXAMPLE.COM-error.log warn;

    root         /var/www/vhosts/EXAMPLE.COM;
    location /.well-known {
        # dont-send to php we need it open for lets encrypt
        # try if it exists, if not redirect back to index.php
        auth_basic off;
        try_files $uri / index.php;
    }

    gzip_vary on;
    gzip_disable msie6;
    gzip_static on;
    gzip_comp_level 9;
    gzip_proxied any;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

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

    # Deny access to any files with a .php extension in the uploads directory
    location ~* /(?:uploads|files)/.*\.php$ {
            deny all;
    }

    # Solve email tracking pixel not found
    location ~ email/(.*).gif {
        try_files $uri /index.php?$args;
    }
    # Solve JS Loading 404 Error
    location ~ (.*).js {
        try_files $uri /index.php?$args;
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico)$ {
        access_log        off;
        log_not_found     off;
        expires           8d;
    }

    # Don't output hidden files
    location ~ /\.git {
        return 404;
    }
    location ~ /\.ht {
        return 404;
    }

    location ~ \.php($|/) {

        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass  unix:/var/run/php-fpm/www.sock;
        fastcgi_index index.php;
        fastcgi_param URI $uri;
        fastcgi_param SERVER_NAME $host;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_read_timeout 300;
        fastcgi_ignore_headers Expires Cache-Control;

        fastcgi_cache_bypass 1;
        fastcgi_no_cache     1;
        fastcgi_cache        fastcgi_cache;
        fastcgi_cache_valid  any 1m;
    }
}

参考記事

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1