I have some experience with Apache but now I switched to Nginx to learn something new. Finally made it to use basic PHP and Let's encrypt on my domain. (yes I'm happy to try new things)
I'd like have some static files with React served by Nginx (I've heard that's something Nginx is good at) and something like REST API with PHP under /API/{RESOURCE}/{ACTION|ID}
URI.
Now, I have directory /API/ and configured (used some googling) to pass everything under domain.tld/(api|API)/ to /API/index.php (I'm using Nette FW).
index.php works as expected with PHP-FPM and displays, but when using endpoint with RESOURCE, it gives me some hash string (or random string) with header Content-Type: application/octet-stream
even though I'm sending contentType from PHP
Here is my 2 domains "virtualhost" config (except HTTPS redirect, which works good);
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name domain.tld *.domain.tld username.tld *.username.cz;
# redirect other domains to main
if ($host != 'domain.tld') {
return 301 https://domain.tld$request_uri;
}
root /home/username/www/domain.tld/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php =404;
}
location /API {
try_files $uri $uri/ /index.php =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
}
ssl_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.tld/privkey.pem; # managed by Certbot
}
Any ideas what's wrong? Thanks