events {}

http {
    include mime.types;

    default_type application/octet-stream;

    # Update charset_types to match updated mime.types.
    # text/html is always included by charset module.
    charset_types
        text/css
        text/plain
        text/vnd.wap.wml
        application/javascript
        application/json
        application/rss+xml
        application/xml;

    charset utf-8;

    server {
        listen 8080;
        listen [::]:8080;
    
        server_name polemictweet.test;
    
        # error_log /var/log/nginx/polemictweet.test.error.log;
        # access_log /var/log/nginx/polemictweet.test.access.log;
    
        root /var/www/html;
        index index.php;

        # location / {
        #     root /var/www;
        #     index index.php index.html index.htm;
        #     try_files $uri $uri/ /index.php?q=$uri&$args;
        # }

        location ~ [^/]\.php(/|$) {
            if (!-e $request_filename){
                rewrite (.+)/([\w-]+)\.php$ /$2.php?rep=$1 last;
            }
            try_files $uri =404;
    
            fastcgi_pass php-fpm:9000;
            fastcgi_index index.php;
    #        fastcgi_intercept_errors on;
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;
            fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            include fastcgi_params;
        }
    
    }
}
