camillele
1 month ago
231
1
Servers

Managing Laravel API & Angular front-end in NGINX

Posted 1 month ago by camillele

I have configured my Laravel API with Angular front-end in my Nginx server as the following. But the Laravel API is not working. Can you help me in configuring the 2 apps properly.

server {
    listen 80;
    server_name my_domain.com www.my_domain.com;
    root /var/www/my_domain.com;

    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location /api {
        alias /var/www/my_domain.com/api/public;
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
     }

    location ~ /\.ht {
        deny all;
    }

}

Please sign in or create an account to participate in this conversation.