server {
    listen 192.168.1.2:80;
    server_name	trtlexplorer.gocrypto.ro;
    charset	utf-8;
    root /var/www/html/turtle-explorer-js;
    index index.php index.html index.htm; 

    access_log /var/log/nginx/trtlexplorer.gocrypto.ro.access.log ;
    error_log /var/log/nginx/trtlexplorer.gocrypto.ro.error.log debug;

    location / {
        try_files $uri $uri/ /index.php;
        
        add_header Access-Control-Allow-Origin "*"; 
        add_header Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT";
        add_header Access-Control-Max-Age "1000";
        add_header Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token";
    }

    location ~* \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_pass  unix:/var/run/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    add_header Access-Control-Allow-Origin "*";
    add_header Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT";
    add_header Access-Control-Max-Age "1000";
    add_header Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token";

    listen 192.168.1.2:443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/trtlexplorer.gocrypto.ro/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/trtlexplorer.gocrypto.ro/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

    ### redirect
    #if ($scheme != "https") {
    #      return 301 https://$host$request_uri;
    #} # managed by Certbot

}
