# Nginx configuration

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name ${NGINX_HOST};

    index index.php index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/html/public;

    gzip on;
    gzip_static on;
    gzip_http_version 1.0;
    gzip_disable "MSIE [1-6].";
    gzip_vary 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 application/javascript image/svg+xml;

    fastcgi_intercept_errors off;
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_read_timeout 180;
    # Remove trailing slashes
    rewrite ^/(.*)/$ /$1 permanent;

    # Remove trailing slashes
    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location ~ /\.ht {

            access_log off;
            log_not_found off;

            deny all;
     }

    location ~* \.ico$ {

        expires 1w;
        access_log off;
    }

    location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {

        try_files $uri $uri/ /index.php?$query_string;

        access_log off;
        log_not_found off;
    }

    location ~* \.(?:css|js)$ {

        try_files $uri $uri/ /index.php?$query_string;

        access_log off;
        log_not_found off;
    }

    add_header "X-UA-Compatible" "IE=Edge,chrome=1";
}

# server {
#     server_name ${NGINX_HOST};

#     listen 443 ssl;
#     fastcgi_param HTTPS on;

#     ssl_certificate /etc/ssl/server.pem;
#     ssl_certificate_key /etc/ssl/server.key;
#     ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;

#     index index.php index.html;
#     error_log  /var/log/nginx/error.log;
#     access_log /var/log/nginx/access.log;
#     root /var/www/html/public;

#     location ~ \.php$ {
#         try_files $uri =404;
#         fastcgi_split_path_info ^(.+\.php)(/.+)$;
#         fastcgi_pass php:9000;
#         fastcgi_index index.php;
#         include fastcgi_params;
#         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#         fastcgi_param PATH_INFO $fastcgi_path_info;
#     }
# }