0

I have configured my Laravel API with Angular front-end in my Nginx server and deployed everything on GCP.Actually I deployed each component on a VM instance separately.

This is the nginx configuration I'm using

events {
#empty
}

http {

server {
        listen 80;

        location / {
            proxy_pass http://frontend;
        }

        location /api/ {
        rewrite ^/api/(.*)$ /$1 break;
        proxy_pass http://backend;
        }

    }

upstream frontend {
   server 172.x.x.4:4200;
}

upstream backend {
        server 172.x.x.7:8000;
    }

}

Inside Angular I'm serving requests to the internal ip address of the VM running Laravel API below

enter image description here

enter image description here

I also served the Laravel API using the internal IP address of the VM:

enter image description here

I can successfully access the Angular fronend from Nginx server but when I make a request, I got address unreachable error:

enter image description here

I stuck with the problem a couple of days, and I'd appreciate any help or improvements.

1 Answer 1

1

The problem was serving requests from Angular directly to Laravel API. Now I changed that to serving to the external IP address of Nginx server and it works.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.