I tried to set up google cloud cdn for my server on google compute engine. I have done everything correct but images on my server are not getting cached. cache hit ratio is n/a. in logs, i am getting 200 status code for http://(ip address)/poweredby.png. So i am assuming fronend ip is not hitting my server but somewhere else. Other than this i can't find any error, all setup is correct. May be i have to change something in my nginx conf file? but idk. Let me know if question is not clear. Thanks,
1 Answers
There are a couple things going on here which are causing you issues, to begin with, the server object you are attempting to cache the image from is not on Google’s network: IP 47.78.15.243 is held by Alibaba.
With Cloud CDN, not all HTTP responses are cacheable. Cloud CDN caches only those responses that meet certain requirements. Some of these requirements are specified by RFC 7234, and others are specific to Cloud CDN.
Most notably for your case, the data to be cached would need to be served by a HTTP(S) backend service or backend bucket (inside of Google Cloud) with Cloud CDN enabled. With Cloud CDN you also must use HTTP(S) load balancing (within Google Cloud) as the origin of content cached by Cloud CDN.
You can find more details about CDN used with Google Cloud Platform here.
- 128
- 4
-
Sorry i forgot to mention that IP is wrong , i changed it just to be secure . real frontend ip is correct one . I am using http load balancer , i will change it to https and will try again. thanks, – Rahul Aug 12 '19 at 07:24
-
I have setup load balancer with https. Now my health check is getting failed. Would you guide me what to do next? – Rahul Aug 14 '19 at 20:32
-
As you have an HTTP(S) LB, I am suspecting you have http(s) health check for the backends. If that is the case, as [indicated in the health check is expecting HTTP 200 OK](https://cloud.google.com/load-balancing/docs/health-check-concepts#criteria-protocol-http) responses to consider them as healthy. Review the responses of your web servers also make sure you created the health check according to the [official guide](https://cloud.google.com/load-balancing/docs/health-checks). – Nur Aug 20 '19 at 00:17
-
Additionally, the [troubleshooting guide](https://cloud.google.com/load-balancing/docs/troubleshooting-health-checks) will also help you identify and correct any problems. Note that you might need to add ingress rules to your GCP firewall allowing the traffic from the [IP ranges](https://cloud.google.com/load-balancing/docs/health-check-concepts#ip-ranges) used by the GCP probe systems to the port the health check will test on the backend instances. – Nur Aug 20 '19 at 00:18