server {
    listen *:80;
    server_name {{ mbstat.subdomain }}.{{ billing.domain }} IPSERVER;

    access_log {{ OS.nginx.dirs.logs }}/mbstat_access.log;
    error_log {{ OS.nginx.dirs.logs }}/mbstat_error.log;
    root {{ mbstat.dirs.chroot }}{{ mbstat.dirs.www }};

    charset utf-8;
    index index.php;
	location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location = /index.php {
        include {{ OS.nginx.dirs.conf }}/fastcgi_params;
        fastcgi_pass  unix:{{ mbstat.software.fpm.socket }};
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME {{ mbstat.dirs.www }}/index.php;
		fastcgi_param DOCUMENT_ROOT {{ mbstat.dirs.www }};
    }

    location ~ ^/(.*)\.(php|php5)$ {
        deny all;
    }

    location ~* ^/(.*)/.*\.(xml|sh|php|php5|phtml|log|sql|txt|html)$ {
        deny all;
    }
    
    location = /robots.txt {
        add_header  Content-Type  text/plain;
        return 200 "User-agent: *\nDisallow: /\n";
    }
}

server {
    listen *:443 ssl;
    server_name {{ mbstat.subdomain }}.{{ billing.domain }};

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;
    ssl_certificate         {{ OS.nginx.dirs.ssl }}/{{ OS.nginx.files.ssl_cert }};
    ssl_certificate_key     {{ OS.nginx.dirs.ssl }}/{{ OS.nginx.files.ssl_key }};

    access_log {{ OS.nginx.dirs.logs }}/mbstat_access.log;
    error_log {{ OS.nginx.dirs.logs }}/mbstat_error.log;
    root {{ mbstat.dirs.chroot }}{{ mbstat.dirs.www }};

    charset utf-8;
    index index.php;
	location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location = /index.php {
        include {{ OS.nginx.dirs.conf }}/fastcgi_params;
        fastcgi_pass  unix:{{ mbstat.software.fpm.socket }};
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME {{ mbstat.dirs.www }}/index.php;
		fastcgi_param DOCUMENT_ROOT {{ mbstat.dirs.www }};
    }

    location ~ ^/(.*)\.(php|php5)$ {
        deny all;
    }

    location ~* ^/(.*)/.*\.(xml|sh|php|php5|phtml|log|sql|txt|html)$ {
        deny all;
    }
    
    location = /robots.txt {
        add_header  Content-Type  text/plain;
        return 200 "User-agent: *\nDisallow: /\n";
    }
}
