HTTPS Load Balancer + Cloud Run links not working - google-cloud-platform

We have a load balancer with a URL map that points to back-end Cloud run services. When we just use cloud run without a load balancer all the assets load as expected. (e.g links to the cloud run service are correct.
When we put the service behind a load balancer we have some weird issues on the links returned from the backend service.
When we hit the load balancer with this path https://custom.domain.com/hello-no-auth we hit the backend service but all the links returned from the service has the wrong paths. The return links from the service miss the URL path we defined in the URL map. For example, icons will come back with his URL
https://custom.domain.com/assets/icon.svg
but we expected they would come back with
https://custom.domain.com/hello-no-auth/assets/icon.svg
Also https://custom.domain.com is not the real domain but just for demonstration

Apologies this was an error with the return links for the assets in the backend service.
To be clear this was not an issue with GCP but the application itself.

Make sure you have not implemented URL rewrite in your project.

Related

Serving react app via Google Cloud Storage and loadbalancer, mapping any urls to index?

I'm setting up React app frontend with Google Cloud Storage and Loadbalancer. During build, index.html and javascript file is uploaded into cloud storage. Loadbalancer points to backend bucket. I can now access react app if I go to http://(loadbalancerip)/index.html
I want to react to handle all routing, and I also want our user to access site via arbitrary path (eg http://(loadbalancerip)/user/details). Is there a way to achieve this with GCP load balancer? Basically I want it to always serve "index.html" regardless of path user is accessing.
I confirmed with GCP support that unfortunately it's not supported. Here is a open feature request https://issuetracker.google.com/issues/194125076
You can achieve this by configuring the website settings on the bucket. Configure the 404 page to serve index.html. When the user hits any random route, they will be served index.html. The only downside I can see is you do get a 404 error in the console, but that doesn't seem to affect operation at all.
My loadbalancer is configured with only the default rule, serving all traffic to the bucket backend (no additional url map rules).
What's happening here is that your load balancer is trying to serve the path (and therefore the associated index.html file) to your users but of course in react there is only one index.html and all the routes within it are controlled by the JS router.
What you can do with cloud storage is assign a "not found" or error page, as mentioned in another answer, where you configure what happens if the file eg, /blog/my_post that the user tries to visit doesn't exist. GCP calls these kinds pages "specialty pages".
You can configure a specialty page, as discussed here:
https://cloud.google.com/storage/docs/static-website#specialty_pages
Hope this helps!
Assuming you are using HTTP(S) External Load Balancer, what you are looking for is URL rewrite.

How to correctly rewrite urls for single page app in GCP static deployment

I'm automating deployment of a single page app that uses client side routing using GCP. So far, cloud build successfully builds my site and deploys the static assets to a bucket. A load balancer points at the bucket and I can successfully access my site over https at the correct url. I configured the specialty pages of the bucket so that 404's go to index.html, and this technically works as expected, but it returns a 404 error code instead of a 200. How should I configure url rewrites so that every request serves index.html as a 200? I see the load balancer has some sort of url rewriting, but the GCP docs are pretty unclear on how I could use this like I have described. I'm hoping the answer is not "deploy an nginx container as a reverse proxy". There has to be a simpler way, ideally that I can just configure via the GCP console.

Ensure load balancer only processes requests from a specific url

I have an api server sat behind a load balancer as part of an AWS elastic beanstalk configuration.
I want to ensure that only my web application can talk to the api server (via the load balancer). My web application is hosted in s3. Can somebody please enlighten me as to the best way to go about this?
Thanks in advance.
S3 simply serves your web app's static files to an end-user's web browser. The application runs in each user's web browser. No code is ever running on S3. As such, there is no way to do what you are asking.
You might want to look into something like API keys, or possibly AWS Cognito.

aws apigateway to internal network load balance of a beanstalk does not work

I am facing a blocker and I am totally stuck.
I use beanstalk with internal network load balancer.
Then I use api gatway and vpc link integration to redirect any api calls to my beanstalk. so this way no one can directly call my beanstalk. Here is my api gtw set up:
And here is my vpc link set up:
Now when I execute api gateway I get:
But when I use a network load balancer but a public facing one everything works. However this does not make sense. The whole point of using vpc link is to be able to talk to internal facing load balancer. Am I making any mistake? Any help is appreciated.
The requests are actually making it to your backend, as indicated by the Apache Tomcat 404 response. You need to make sure Tomcat is configured to serve up the path API Gateway is requesting.

How to deploy wcf service on amazon elasticbeanstalk,

I am using AWS Toolkit to deploy the wcf service on amazon elastic beanstalk, after deployment it shows environment is healthy but when i browse the URL then it redirected to the IIS Server Page, i am unable to access the service url , please let me know how to access the hosted service
Thanks in advance
Follow the standard procedure to deploy a ASP.net project. Here is the link for that : Link
But for you WCF service you need a simple html page at project root. E.g. index.html or default.html. Load balancer need this page to check if the instance is available or not. Without this html page load balancer will consider the instance dead and remove it.