server {
    server_name ${APP_HOST} localhost nginx;

    root /application/public;

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

    location ~ ^/index\.php(/|$) {
        if ($request_method = 'OPTIONS') {
        	add_header 'Access-Control-Allow-Origin' $http_origin;
        	add_header 'Access-Control-Allow-Credentials' 'true';
        	add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE';
        	add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Expeditor-Domain,Authorization';
        	add_header 'Access-Control-Max-Age' 1728000;
        	add_header 'Content-Type' 'text/plain charset=UTF-8';
        	add_header 'Content-Length' 0;
        	return 204;
        }

        add_header 'Access-Control-Allow-Origin' $http_origin;
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Expeditor-Domain,Authorization';

        fastcgi_pass php:9001;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    error_log /var/log/nginx/dot_dot_error.log;
    access_log /var/log/nginx/dot_dot_access.log;
}