#--------------------------------------------------------
# CI4 server configuration
#--------------------------------------------------------

server {
    # listen 443 ssl;
    listen 80;
    # server_name sekolah.sch.id;
    # listen [::]:80 ipv6only=on default_server;

    index index.php index.html;
    root /var/www/html/cbt/public;
    charset utf-8;

    client_max_body_size 20m;

    # SSL for 443
    #ssl_certificate /etc/nginx/ssl/ssl-cert-snakeoil.pem;
    #ssl_certificate_key /etc/nginx/ssl/ssl-cert-snakeoil.key;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        error_log /dev/null;
        access_log off;
    }

    location ~ .*\.(js|css)?$
    {
        expires      12h;
        error_log /dev/null;
        access_log off; 
    }
        # Forbidden files or directories
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    # Handle all php files (which will always be just /index.php)
    # via factcgi PHP-FPM unix socket
        location ~* \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass candy:9000;
            fastcgi_index index.php;
            # For comfortable debugging
            fastcgi_read_timeout 1000;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}