0

I have a HTTP Load Balancer setup as shown below. The content will be routed to backend bucket or an instance group depending on the url.

enter image description here The firewall allows everything on the port 80

enter image description here

When I tried accessing the API using the load balanced IP, I get the error Status Code: 401 Unauthorized.

Here is the Stackdriver logging snapshot of that particular request.

    http://3xxxxxx5/api/GetAccountTransaction?key=AIzaSyC3xxxxxxMHNAxKM
     1xxxxxx06 - "POST http://3xxxxxx5/api/GetAccountTransaction?key=AIzaSyC3xxxxxxMHNAxKM" 401 494 "http://3xxxxxx5/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
    Expand all | Collapse all {
     httpRequest: {
      referer:  "http://3xxxxxx5/"   
      remoteIp:  "1xxxxxx06"   
      requestMethod:  "POST"   
      requestSize:  "559"   
      requestUrl:  "http://3xxxxxx5/api/GetAccountTransaction?key=AIzaSyC3xxxxxxMHNAxKM"   
      responseSize:  "494"   
      status:  401   
      userAgent:  "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"   
     }
     insertId:  "efo39lf8k5sux"  
     jsonPayload: {
      @type:  "type.googleapis.com/google.cloud.loadbalancing.type.LoadBalancerLogEntry"   
      statusDetails:  "response_sent_by_backend"   
     }
     logName:  "projects/sixxxxxx4204/logs/requests"  
     receiveTimestamp:  "2018-03-30T12:09:37.539673973Z"  
     resource: {
      labels: {
       backend_service_name:  ""    
       forwarding_rule_name:  "prepay-ip-address"    
       project_id:  "sixxxxxx4204"    
       target_proxy_name:  "prepay-service-target-proxy"    
       u

rl_map_name:  "prepay-service"    
   zone:  "global"    
  }
  type:  "http_load_balancer"   
 }
 severity:  "WARNING"  
 spanId:  "5da2dc551e28dbcc"  
 timestamp:  "2018-03-30T12:09:36.491864533Z"  
 trace:  "projects/sixxxxxx4204/traces/52617f14af59859ee38e759f605bc545"  
}

However, when I use the same request but with the external IP of the VM instance, it works.

What authentication does this error from the load balancer refer to?

Jesse Scherer
  • 1,492
  • 9
  • 26
  • Clarify "When I tried accessing the API using the load balanced IP": how did you access, was it internal or external, etc. – Oliver Apr 02 '18 at 13:19
  • I accessed the API from an Angular App using the External IP of the load balancer (35.xx.xx.xx). In fact the static files of the angular app also served by the same load balancer (forwarded to cloud storage bucket). When I access the IP address from my laptop browser, the static files are returned by the load balancer, but the APIs failing with the 401 Unauthorised error. – kanagaraj palanisamy Apr 02 '18 at 13:41
  • The required API are enabled and the correct permissions are set on the role or service account used? You have the proper firewall rules for the load balancer? – Oliver Apr 02 '18 at 18:36
  • I would recommend you to move this to Serverfault. – Katie Sinatra Apr 11 '18 at 15:52

0 Answers0