Home > Net >  Asp.net Core behind a Nginx Ingress Controller on AWS EKS got "502 Bad Gateway"
Asp.net Core behind a Nginx Ingress Controller on AWS EKS got "502 Bad Gateway"

Time:10-19

I follow the guide from enter image description here

CodePudding user response:

The asp.net core sample listen to port 80 and not 3001, update your deployment:

...
containers:
- image: mcr.microsoft.com/dotnet/samples:aspnetapp
  imagePullPolicy: Always
  name: moba-web-portal
  ports:
  - containerPort: 80
...

And the service spec:

...
kind: Service
metadata:
  name: moba-web-portal
spec:
  selector:
    app: moba-web-portal
  ports:
  -  protocol: TCP
     port: 3001
     targetPort: 80
...

Check the log of the pod:

{"EventId":14,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://[::]:80","State":{"Message":"Now listening on: http://[::]:80","address":"http://[::]:80","{OriginalFormat}":"Now listening on: {address}"}}

Try: http://api.kmsmoba.com:3001/moba takes you to the homepage "Welcome to .NET"

  • Related