502 Bad Gateway issue with some containers - docker
I installed NGINX Ingress in the cluster, but when i am trying to access it i am getting 502
These are the steps that i have followed to install NGINX Ingress
kubectl apply -f common/ns-and-sa.yaml
kubectl apply -f common/default-server-secret.yaml
kubectl apply -f common/nginx-config.yaml
kubectl apply -f common/vs-definition.yaml
kubectl apply -f common/vsr-definition.yaml
kubectl apply -f rbac/rbac.yaml
kubectl apply -f daemon-set/nginx-ingress.yaml
This is the Deployment which i am trying to access from Ingress Controller
apiVersion: apps/v1
kind: Deployment
metadata:
name: ngtest
namespace: practice
labels:
app: ngtest
spec:
replicas: 1
selector:
matchLabels:
app: ngtest
template:
metadata:
labels:
app: ngtest
spec:
imagePullSecrets:
- name: testkuldeepsecret
containers:
- name: ngtest
image: nginx:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: ngtest
namespace: practice
labels:
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
selector:
app: ngtest
With the Cluster IP i am able to access the nginx
Now i configured Ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: practice-ingress
namespace: practice
spec:
rules:
- host: practice.example.com
http:
paths:
- path: /
backend:
serviceName: ngtest
servicePort: 80
Ingress Description
Name: practice-ingress
Namespace: practice
Address:
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
practice.example.com
/ ngtest:80 (10.32.0.7:80)
Annotations:
kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{},"name":"practice-ingress","namespace":"practice"},"spec":{"rules":[{"host":"practice.example.com","http":{"paths":[{"backend":{"serviceName":"ngtest","servicePort":80},"path":"/"}]}}]}}
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal AddedOrUpdated 46m nginx-ingress-controller Configuration for practice/practice-ingress was added or updated
Normal AddedOrUpdated 46m nginx-ingress-controller Configuration for practice/practice-ingress was added or updated
Its clear that ingress will forward it to Port 80 and ngtest service also exposed on port 80
I added IP address and practice.example.com in my host file.
So when i try to access http://practice.example.com i am getting 502
Ingress NGINX Pod Logs
10.32.0.1 - - [14/Mar/2020:07:37:53 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:37:56 [error] 30#30: *13 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.32.0.7:80/favicon.ico", host: "practice.example.com", referrer: "http://practice.example.com/"
2020/03/14 07:37:56 [error] 30#30: *15 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET / HTTP/1.1", upstream: "http://10.32.0.7:80/", host: "practice.example.com"
10.32.0.1 - - [14/Mar/2020:07:37:56 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://practice.example.com/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
10.32.0.1 - - [14/Mar/2020:07:37:56 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:37:59 [error] 30#30: *13 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.32.0.7:80/favicon.ico", host: "practice.example.com", referrer: "http://practice.example.com/"
10.32.0.1 - - [14/Mar/2020:07:37:59 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://practice.example.com/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:43:03 [error] 30#30: *19 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET / HTTP/1.1", upstream: "http://10.32.0.7:80/", host: "practice.example.com"
10.32.0.1 - - [14/Mar/2020:07:43:03 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:43:06 [error] 30#30: *19 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.32.0.7:80/favicon.ico", host: "practice.example.com", referrer: "http://practice.example.com/"
10.32.0.1 - - [14/Mar/2020:07:43:06 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://practice.example.com/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:43:09 [error] 30#30: *19 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET / HTTP/1.1", upstream: "http://10.32.0.7:80/", host: "practice.example.com"
10.32.0.1 - - [14/Mar/2020:07:43:09 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:43:12 [error] 30#30: *19 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.32.0.7:80/favicon.ico", host: "practice.example.com", referrer: "http://practice.example.com/"
10.32.0.1 - - [14/Mar/2020:07:43:12 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://practice.example.com/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:52:07 [error] 30#30: *25 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET /practice HTTP/1.1", upstream: "http://10.32.0.7:80/practice", host: "practice.example.com"
10.32.0.1 - - [14/Mar/2020:07:52:07 +0000] "GET /practice HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:52:11 [error] 30#30: *25 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.32.0.7:80/favicon.ico", host: "practice.example.com", referrer: "http://practice.example.com/practice"
10.32.0.1 - - [14/Mar/2020:07:52:11 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://practice.example.com/practice" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:54:48 [error] 30#30: *29 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.32.0.7:80/favicon.ico", host: "practice.example.com", referrer: "http://practice.example.com/practice"
10.32.0.1 - - [14/Mar/2020:07:54:48 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://practice.example.com/practice" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 07:54:58 [error] 30#30: *29 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.32.0.7:80/favicon.ico", host: "practice.example.com", referrer: "http://practice.example.com/practice"
10.32.0.1 - - [14/Mar/2020:07:54:58 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://practice.example.com/practice" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 08:13:36 [error] 30#30: *32 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET / HTTP/1.1", upstream: "http://10.32.0.7:80/", host: "practice.example.com"
10.32.0.1 - - [14/Mar/2020:08:13:36 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
2020/03/14 08:13:39 [error] 30#30: *32 connect() failed (113: No route to host) while connecting to upstream, client: 10.32.0.1, server: practice.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.32.0.7:80/favicon.ico", host: "practice.example.com", referrer: "http://practice.example.com/"
10.32.0.1 - - [14/Mar/2020:08:13:39 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://practice.example.com/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" "-"
Resources that were running
root#ip-172-31-12-0:/home/ubuntu# kubectl get all --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system pod/coredns-6955765f44-7fxkh 1/1 Running 0 6d13h
kube-system pod/coredns-6955765f44-l7dkf 1/1 Running 0 6d13h
kube-system pod/etcd-ip-172-31-12-0 1/1 Running 0 6d13h
kube-system pod/kube-apiserver-ip-172-31-12-0 1/1 Running 0 3h2m
kube-system pod/kube-controller-manager-ip-172-31-12-0 1/1 Running 1 6d13h
kube-system pod/kube-proxy-2h672 1/1 Running 1 6d13h
kube-system pod/kube-proxy-7zc4j 1/1 Running 0 6d13h
kube-system pod/kube-scheduler-ip-172-31-12-0 1/1 Running 1 6d13h
kube-system pod/weave-net-wrrml 2/2 Running 0 6d13h
kube-system pod/weave-net-wxjv4 2/2 Running 4 6d13h
nginx-ingress pod/nginx-ingress-9hsck 1/1 Running 0 58m
nginx-ingress pod/nginx-ingress-xvhfg 1/1 Running 0 58m
practice pod/customer-855c6d9bc8-8pq8v 1/1 Running 0 14h
practice pod/ngtest-6c5ff8c7df-2867b 1/1 Running 0 46m
practice pod/some-mysql-7896cfbb4c-zlpl8 1/1 Running 0 38h
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 6d13h
kube-system service/kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 6d13h
practice service/customer-service ClusterIP 10.110.222.12 <none> 80/TCP 14h
practice service/ngtest ClusterIP 10.105.115.222 <none> 80/TCP 46m
practice service/some-mysql ClusterIP None <none> 3306/TCP 38h
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
kube-system daemonset.apps/kube-proxy 2 2 2 2 2 beta.kubernetes.io/os=linux 6d13h
kube-system daemonset.apps/weave-net 2 2 2 2 2 <none> 6d13h
nginx-ingress daemonset.apps/nginx-ingress 2 2 2 2 2 <none> 58m
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/coredns 2/2 2 2 6d13h
practice deployment.apps/customer 1/1 1 1 14h
practice deployment.apps/ngtest 1/1 1 1 46m
practice deployment.apps/some-mysql 1/1 1 1 38h
NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/coredns-6955765f44 2 2 2 6d13h
practice replicaset.apps/customer-855c6d9bc8 1 1 1 14h
practice replicaset.apps/ngtest-6c5ff8c7df 1 1 1 46m
practice replicaset.apps/some-mysql-7896cfbb4c 1 1 1 38h
No route to host means the nginx ingress controller was not able to connect to pod IP. Check if you have any firewall between the node where nginx ingress controller is running and the node where the pod is running.
Did try using https://github.com/kubernetes/ingress-nginx? Most of the time we use wrong ingress.
Related
Swagger UI is blank or empty when i try t connect it to kong.yaml
This is the swagger of port 8099 swagger of 8099 then after i connect it to kong kong swagger the tab name is changing to Swagger UI that means its working but its empty. Any Solution? //kong.yaml for swagger _format_version: "2.1" _transform: true services: # ------ Swagger port ------- - host: host.docker.internal port: 8099 name: swagger-service path: /swagger-ui/index.html routes: - name: swagger-service paths: - /swagger strip_path: true After i enter the port http://localhost:8000/swagger this will show kong | 172.24.0.1 - - [24/May/2022:07:48:11 +0000] "GET /favicon-16x16.png HTTP/1.1" 404 48 "http://localhost:8000/swagger" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53"
Ingress Nginx rules doesn't get followed always
I got 2 spring app pods deployed in k8 cluster. 1 replica each. Both have their cluster-ip services exposing the services. /upstream/agentLabs/makeotherTierCall should forward to prevlab deployment /agentLabs/makeOtherTierCall /downstream/basics/hello should forward to newlab deployment /basics/hello I am using ingress-nginx to redirect the traffic with following rules. ingress-service.yml apiVersion: networking.k8s.io/v1 # UPDATE API kind: Ingress metadata: namespace: javaspace name: ingress-service annotations: kubernetes.io/ingress.class: 'nginx' nginx.ingress.kubernetes.io/use-regex: 'true' # ADD ANNOTATION nginx.ingress.kubernetes.io/rewrite-target: /$1 # UPDATE ANNOTATION spec: rules: - http: paths: - path: /upstream?(.*) # UPDATE PATH pathType: Prefix # ADD PATHTYPE backend: service: # UPDATE SERVICE FIELDS name: prevlab-cluster-ip-service port: number: 8080 - path: /downstream?(.*) # UPDATE PATH pathType: Prefix # ADD PATHTYPE backend: service: # UPDATE SERVICE FIELDS name: newlab-cluster-ip-service port: number: 8080 The issue is when I make any call (both 1 and 2) sometimes the ingress controller forwards the traffic correctly and sometimes it doesn't and I get 404. Basically, what I am observing is that alternatively the traffic is getting routed to both cluster-ip services one after the other. for eg. if I make /upstream/agentLabs/makeotherTierCall request 2 times, at first it forwards wrongly to newlab cluster-ip service (giving back 404), and then next it forwards correctly to prevlab cluster-ip service (giving back 200). ingress-nginx controller setup kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.1/deploy/static/provider/cloud/deploy.yaml ingress-controller logs 192.168.65.3 - - [24/Sep/2021:10:04:21 +0000] "GET /upstream/agentLabs/makeOtherTierCall HTTP/2.0" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" 45 0.008 [javaspace-prevlab-cluster-ip-service-8080] [] 10.1.0.181:8080 12 0.007 200 24ae53531ce4d7109004f81e79534ca4 192.168.65.3 - - [24/Sep/2021:10:04:21 +0000] "GET /upstream/agentLabs/makeOtherTierCall HTTP/2.0" 404 286 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" 45 0.006 [javaspace-prevlab-cluster-ip-service-8080] [] 10.1.0.179:8080 286 0.005 404 1a32efb3a9dc21cce01b908afeb0248a 192.168.65.3 - - [24/Sep/2021:10:04:22 +0000] "GET /upstream/agentLabs/makeOtherTierCall HTTP/2.0" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" 45 0.007 [javaspace-prevlab-cluster-ip-service-8080] [] 10.1.0.181:8080 12 0.007 200 542bd4abba25be5a416deca1152cb29b 192.168.65.3 - - [24/Sep/2021:10:04:22 +0000] "GET /upstream/agentLabs/makeOtherTierCall HTTP/2.0" 404 286 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" 45 0.008 [javaspace-prevlab-cluster-ip-service-8080] [] 10.1.0.179:8080 286 0.007 404 aaea8e3bf60dab81ef7454d51863a22d 192.168.65.3 - - [24/Sep/2021:10:07:23 +0000] "GET /downstream/basics/hello HTTP/2.0" 404 306 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" 35 0.009 [javaspace-newlab-cluster-ip-service-8080] [] 10.1.0.181:8080 306 0.009 404 178bd79cc71b73f7a337a2652322d65f 192.168.65.3 - - [24/Sep/2021:10:07:23 +0000] "GET /downstream/basics/hello HTTP/2.0" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" 35 0.002 [javaspace-newlab-cluster-ip-service-8080] [] 10.1.0.179:8080 12 0.003 200 280d2b7974ae38a467237cc6cf437b98 192.168.65.3 - - [24/Sep/2021:10:07:24 +0000] "GET /downstream/basics/hello HTTP/2.0" 404 306 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" 35 0.008 [javaspace-newlab-cluster-ip-service-8080] [] 10.1.0.181:8080 306 0.008 404 4e237232b4c53c9bb90e7bb59c15e916 192.168.65.3 - - [24/Sep/2021:10:07:24 +0000] "GET /downstream/basics/hello HTTP/2.0" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" 35 0.003 [javaspace-newlab-cluster-ip-service-8080] [] 10.1.0.179:8080 12 0.002 200 be0cf532a972ec0d783e15869470f579 Using Docker Desktop's Kubernetes. Kubernetes 1.21.2 What am I doing wrong here? Is this default behavior? Do I need to do some additional config?
Nevermind. I had done a very small but very stupid mistake. In case someone comes wandering around here: I had used the same label for my 2 backend services. And for each of the cluster-IP services used the same selector. Hence, I was seeing inconsistent behavior.
Nginx config issue : vue.js history mode on k8s cluster
I'm trying to deploy a vue.js application on a k8s cluster using docker and docker-compose. I'm also using a nginx ingress controller. I'm using a configmap to load my custom nginx conf, according to this : https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations As a matter of fact my application loads properly, but refreshing a page other than the homepage results in a 404 error. And that's just the same if I try and access any given page by its URL. What am I doing wrong ? I'm using kubectl in command line to deploy. Here's my Dockerfile : # build environment FROM node:12.2.0-alpine as build WORKDIR /app ENV PATH /app/node_modules/.bin:$PATH COPY ./[project folder]/ . RUN npm config set unsafe-perm true RUN npm install --silent RUN npm install #vue/cli#3.7.0 -g RUN npm run build # production environment FROM nginx:1.16.0-alpine COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] My ingress.yaml: apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: foo-ingress-lb annotations: kubernetes.io/ingress.class: "nginx" kubernetes.io/tls-acme: "true" cert-manager.io/issuer: letsencrypt-prod nginx.ingress.kubernetes.io/use-regex: "true" spec: tls: - hosts: - www.foo.com # This assumes tls-secret exists and the SSL # certificate contains a CN for foo.bar.com secretName: tls-secret rules: - host: www.foo.com http: paths: - path: /.* pathType: Prefix backend: service: name: my-service port: number: 80 My configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: vue-config labels: app: vue-config data: default.conf: server { listen 8080 default; root /var/www/app; location / { try_files $uri $uri/ /index.html; } } service.yaml apiVersion: v1 kind: Service metadata: name: my-service spec: ports: - port: 80 name: http-front protocol: TCP targetPort: 80 selector: app: my-app And finally my deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: "my-deployment" spec: replicas: 1 selector: matchLabels: app: "my-app" template: metadata: labels: app: "my-app" spec: containers: - name: "vue-nginx" image: XXX/nginx:alpine volumeMounts: - mountPath: /var/www/app name: html-files - mountPath: /etc/nginx/conf.d name: config ports: - containerPort: 8080 imagePullPolicy: "Always" - name: "vue" image:XXX/my_image:latest volumeMounts: - mountPath: /var/www/app name: html-files ports: - containerPort: 8080 imagePullPolicy: "Always" imagePullSecrets: - name: registry-secret restartPolicy: Always volumes: - name: html-files emptyDir: {} - name: config configMap: name: vue-config kubectl logs -n kube-system nginx-ingress-xxx 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET / HTTP/2.0" 200 3114 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 684 0.019 [default-maorie-service-front-80] [] 100.64.0.205:80 3114 0.016 200 eaa454a87cf4cee8929f15f3ecd75dcc 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /css/app.8b722d7e.css HTTP/2.0" 200 11488 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 85 0.001 [default-maorie-service-front-80] [] 100.64.0.205:80 11488 0.000 200 6cce6ff53f0b3b57807eef9df4ab1e2d 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /css/chunk-vendors.2072d5c4.css HTTP/2.0" 200 398846 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 36 0.005 [default-maorie-service-front-80] [] 100.64.0.205:80 398846 0.004 200 ea59b05209b2d7e910ac380ceda13b3f 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /js/app.147dc57f.js HTTP/2.0" 200 46213 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 38 0.002 [default-maorie-service-front-80] [] 100.64.0.205:80 46213 0.000 200 cc6b44751229b2ef4a279defae770da5 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /js/chunk-vendors.ed6dc4c7.js HTTP/2.0" 200 590498 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 36 0.004 [default-maorie-service-front-80] [] 100.64.0.205:80 590498 0.004 200 49e3731caaf832ec21e669affa6c722d 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /css/chunk-2678b26c.8577e149.css HTTP/2.0" 200 2478 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 38 0.002 [default-maorie-service-front-80] [] 100.64.0.205:80 2478 0.000 200 001a3ce8a18e6c9b8433f84ddd7a0412 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /css/chunk-2470e996.066be083.css HTTP/2.0" 200 72983 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 94 0.006 [default-maorie-service-front-80] [] 100.64.0.205:80 72983 0.008 200 092515d8d6804324d24fc3fabad87eba 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /css/chunk-30fff3f3.e2b55839.css HTTP/2.0" 200 20814 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 38 0.001 [default-maorie-service-front-80] [] 100.64.0.205:80 20814 0.000 200 f9f78eb5b9b1963a06d386a1c9421189 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /css/chunk-3db1ab7a.0a0e84c4.css HTTP/2.0" 200 3329 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 38 0.001 [default-maorie-service-front-80] [] 100.64.0.205:80 3329 0.000 200 d66e57d023158381d0eb7b4ce0fcf4c1 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /css/chunk-7ac8b24c.353e933b.css HTTP/2.0" 200 10170 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 38 0.003 [default-maorie-service-front-80] [] 100.64.0.205:80 10170 0.000 200 fcb3655b95599822f79587650ca0c017 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /js/chunk-2678b26c.e69fb49a.js HTTP/2.0" 200 103310 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 37 0.009 [default-maorie-service-front-80] [] 100.64.0.205:80 103310 0.008 200 3423ac43407db755c1a23bca65ca8a0e 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /js/canvg.a381dd7b.js HTTP/2.0" 200 143368 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 31 0.009 [default-maorie-service-front-80] [] 100.64.0.205:80 143368 0.008 200 61d6e047f66dc9b36c836c1b49d2452d 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /js/chunk-3db1ab7a.6fc5dc72.js HTTP/2.0" 200 8157 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 37 0.009 [default-maorie-service-front-80] [] 100.64.0.205:80 8157 0.008 200 90231ff6f00b168861f10511ab58ae29 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /js/chunk-6e83591c.163e5349.js HTTP/2.0" 200 22685 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 37 0.009 [default-maorie-service-front-80] [] 100.64.0.205:80 22685 0.008 200 7d56be2022473cc6055cf8101090fdb7 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /js/chunk-7ac8b24c.1a4727cd.js HTTP/2.0" 200 37637 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 37 0.009 [default-maorie-service-front-80] [] 100.64.0.205:80 37637 0.008 200 e38c234d67700b4f4e2ffe4125bed445 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /css/chunk-b09da666.b0ea57ae.css HTTP/2.0" 200 1414 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 38 0.009 [default-maorie-service-front-80] [] 100.64.0.205:80 1414 0.008 200 e8b8c016069e4c59c929b61e8ba5502b 195.154.69.132 - - [21/Jan/2021:09:23:06 +0000] "GET /js/chunk-b09da666.e5df996b.js HTTP/2.0" 200 1228 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 38 0.009 [default-maorie-service-front-80] [] 100.64.0.205:80 1228 0.008 200 4964cb095baf55cebed49bbcc3fe1af2 195.154.69.132 - - [21/Jan/2021:09:23:08 +0000] "GET /js/chunk-30fff3f3.f6defc09.js HTTP/2.0" 200 3386928 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 37 1.634 [default-maorie-service-front-80] [] 100.64.0.205:80 3386928 1.632 200 4ed3d78d4d72be629deaf579670168ff 195.154.69.132 - - [21/Jan/2021:09:23:08 +0000] "GET /img/logo.956610d4.png HTTP/2.0" 200 6620 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 75 0.355 [default-maorie-service-front-80] [] 100.64.0.205:80 6620 0.352 200 c16abf3b959c147ab469b73fd548dc95 195.154.69.132 - - [21/Jan/2021:09:23:13 +0000] "GET /img/icons/favicon-32x32.png HTTP/2.0" 200 1690 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 34 0.583 [default-maorie-service-front-80] [] 100.64.0.205:80 1690 0.584 200 f7c2c72bebd294c07f174fa91c4fd40f 195.154.69.132 - - [21/Jan/2021:09:23:15 +0000] "GET /js/pdfmake.b17ba0e4.js HTTP/2.0" 200 2127948 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 32 8.697 [default-maorie-service-front-80] [] 100.64.0.205:80 2127948 8.696 200 edb7e05dd9d87cfc91bc5986b80ff8a8 195.154.69.132 - - [21/Jan/2021:09:23:20 +0000] "GET /js/xlsx.a4e6cbf1.js HTTP/2.0" 200 924857 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 30 13.529 [default-maorie-service-front-80] [] 100.64.0.205:80 924857 13.528 200 8ffa5bb28d9d255e69021ccce35a4dfe 195.154.69.132 - - [21/Jan/2021:09:23:20 +0000] "GET /js/chunk-2470e996.bc9a0d30.js HTTP/2.0" 200 9615968 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 37 13.992 [default-maorie-service-front-80] [] 100.64.0.205:80 9615968 13.992 200 6e42aeb8a644afa385aa8a166fbb5860 195.154.69.132 - - [21/Jan/2021:09:23:31 +0000] "GET /js/chunk-2470e996.bc9a0d30.js HTTP/2.0" 200 9615968 "https://dev.maorie.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" 36 10.464 [default-maorie-service-front-80] [] 100.64.0.205:80 9615968 10.464 200 f8eb813e1091ed422525611f61a17d68 195.154.69.132 - - [21/Jan/2021:09:35:01 +0000] "GET /service-worker.js HTTP/2.0" 200 1069 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0" 919 0.004 [default-maorie-service-front-80] [] 100.64.0.205:80 1069 0.004 200 a03dd0f950c451a8016823c28a958dae 195.154.69.132 - - [21/Jan/2021:09:35:01 +0000] "GET /precache-manifest.2a722082efdadd279fa63223d8219496.js HTTP/2.0" 200 3232 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0" 51 0.009 [default-maorie-service-front-80] [] 100.64.0.205:80 3232 0.008 200 e8cdcd5bc52b8a9a8777de4a1e680f1d 195.154.69.132 - - [21/Jan/2021:09:35:05 +0000] "GET /service-worker.js HTTP/2.0" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0" 50 0.002 [default-maorie-service-front-80] [] 100.64.0.205:80 0 0.000 304 c0e319cf30abfffd9dc13da6bad8453c 193.32.164.26 - - [21/Jan/2021:10:06:33 +0000] "\x03\x00\x00/*\xE0\x00\x00\x00\x00\x00Cookie: mstshash=Administr" 400 150 "-" "-" 0 0.021 [] [] - - - - 5de24d60404270018011b04db4194bd4 193.32.164.26 - - [21/Jan/2021:10:06:33 +0000] "\x03\x00\x00/*\xE0\x00\x00\x00\x00\x00Cookie: mstshash=Administr" 400 150 "-" "-" 0 0.019 [] [] - - - - 860c19f03a627f6de82bd538fc0c68f1 195.154.69.132 - - [21/Jan/2021:10:20:14 +0000] "\xAA\xAA\xAA\xAAUUUUUUUU\xAA\xAA\xAA\xAAUUUU\xAA\xAA\xAA\xAAUUUU\xAA\xAA\xAA\xAAUUUU\xAA\xAA\xAA\xAAUUUU\xAA\xAA\xAA\xAAUUUU\xAA\xAA\xAA\xAAUUUU\xAA\xAA\xAA\xAA" 400 150 "-" "-" 0 0.015 [] [] - - - - a604c37ad900da39307e364e55f4db90 195.154.69.132 - - [21/Jan/2021:10:25:19 +0000] "GET /service-worker.js HTTP/2.0" 200 1069 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0" 914 0.015 [default-maorie-service-front-80] [] 100.64.0.205:80 1069 0.016 200 5856773011e3f4887361fd864e7ca3cc 195.154.69.132 - - [21/Jan/2021:10:25:24 +0000] "GET /service-worker.js HTTP/2.0" 200 1069 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0" 13 0.001 [default-maorie-service-front-80] [] 100.64.0.205:80 1069 0.000 200 a2157ea238ab87fa87f59262a4023076 5.188.210.227 - - [21/Jan/2021:10:30:35 +0000] "\x05\x01\x00" 400 150 "-" "-" 0 0.622 [] [] - - - - b42d10d3b0579c8c55d3febbebc1da59 5.188.210.227 - - [21/Jan/2021:10:31:47 +0000] "\x04\x01\x00P\x05\xBC\xD2\xE3\x00" 400 150 "-" "-" 0 0.380 [] [] - - - - 77536a3304f9d249198240df300dec18 195.154.69.132 - - [21/Jan/2021:10:44:04 +0000] "GET / HTTP/1.1" 200 3114 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0" 255 0.013 [default-maorie-service-front-80] [] 100.64.0.205:80 3114 0.012 200 2e568e4805e1bfd0ccdfd8e91e5807c3 157.245.176.143 - - [21/Jan/2021:10:54:31 +0000] "SSTP_DUPLEX_POST /sra_{BA195980-CD49-458b-9E23-C84EE0ADCD75}/ HTTP/1.1" 400 150 "-" "-" 192 0.000 [] [] - - - - e28b66acd059bf0d8c9264395c119aad E0121 11:00:21.036598 6 leaderelection.go:357] Failed to update lock: etcdserver: request timed out 195.154.69.132 - - [21/Jan/2021:11:21:48 +0000] "GET / HTTP/1.1" 308 164 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0" 255 0.000 [default-maorie-service-front-80] [] - - - - 5cf25e7eba89ae4a9c06d81532951824 18.136.126.138 - - [21/Jan/2021:11:46:06 +0000] "\x16\x03\x01\x02\x00\x01\x00\x01\xFC\x03\x03\x8F^\xE5#p\xB3\xA4\xA7H\xB1`\xF7\x9FZ\xF7=|\xA6\x82" 400 150 "-" "-" 0 0.494 [] [] - - - - 83a6709f7eaa820c4f9829979de617a4 195.154.69.132 - - [21/Jan/2021:12:56:23 +0000] "CONNECT ip.ws.126.net:443 HTTP/1.1" 400 150 "-" "-" 0 0.913 [] [] - - - - 1ddfb9204b6efa687d05a138f213bef2 222.186.136.150 - - [21/Jan/2021:13:15:16 +0000] "CONNECT ip.ws.126.net:443 HTTP/1.1" 400 150 "-" "-" 0 0.257 [] [] - - - - 87c08e487d0c9a7e786685c8dd1a589b 64.227.97.195 - - [21/Jan/2021:13:18:32 +0000] "\x00\x0E8\x97\xAB\xB2\xBB\xBA\xB1\x1D\x90\x00\x00\x00\x00\x00" 400 150 "-" "-" 0 0.152 [] [] - - - - 4d89d6868e909990414d125fe5e3862d 167.71.102.181 - - [21/Jan/2021:13:19:52 +0000] "\x00\x0E8f:d5\xBE\xC3\xBC_\x00\x00\x00\x00\x00" 400 150 "-" "-" 0 0.086 [] [] - - - - efbe674f606c5bf20e6903da0ae39855 I0121 14:15:35.862702 6 controller.go:144] "Configuration changes detected, backend reload required" I0121 14:15:35.865621 6 event.go:282] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"maorie-ingress-lb", UID:"a5ad31d8-c913-4139-a721-2a5c0f7119d3", APIVersion:"networking.k8s.io/v1beta1", ResourceVersion:"5627714245", FieldPath:""}): type: 'Normal' reason: 'Sync' Scheduled for sync I0121 14:15:36.262759 6 controller.go:161] "Backend successfully reloaded" I0121 14:15:36.265762 6 event.go:282] Event(v1.ObjectReference{Kind:"Pod", Namespace:"kube-system", Name:"nginx-ingress-29787", UID:"07845f40-87d4-40ce-83d1-01a3d37011c1", APIVersion:"v1", ResourceVersion:"4834374834", FieldPath:""}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration
As said in the comments, I finally realised the nginx configmap was not needed, as the docker image embedded an nginx on its own. Removing the configmap instructions in deployment.yaml did the trick !
I got problem while using Nginx to direct requests to services defined in docker-compose.yml
I'm setting up an app with multiple containers, and use nginx to redirect requests to correct container. However, I got stuck with the 502 Bad Gateway error. Actually, the code is from a course on Udemy: Docker and Kubernetes. I just copy and paste the code, it ran on instructor machine, but not mine. I tried on my windows and my macbook, restart docker, but still no hope. I looked for solutions on other stackoverflow posts, some other articles, but none of them tell me why it works on others' machines, but not mine. Here is the repo of the code. docker-compose.yml (full code): version: "3" services: postgres: ... redis: ... nginx: restart: always build: dockerfile: Dockerfile.dev context: ./nginx ports: - "3050:80" api: ... client: ... worker: ... nginx/Dockerfile.dev FROM nginx COPY ./default.conf /etc/nginx/conf.d/default.conf nginx/default.conf upstream client { server client:3000; } upstream api { server api:5000; } server { listen 80; server_name localhost; location / { proxy_pass http://client; } location /api { rewrite /api/(.*) /$1 break; proxy_pass http://api; } } It runs just fine on instructor's machine and other learners', but not on my machines. I got error when connecting http://localhost:3050 and http://localhost:3050/api: nginx_1 | 2019/07/08 02:52:35 [error] 6#6: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.25.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://125.235.4.59:3000/", host: "localhost:3050" nginx_1 | 172.25.0.1 - - [08/Jul/2019:02:52:35 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36" "-" nginx_1 | 2019/07/08 02:52:57 [error] 6#6: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.25.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://125.235.4.59:3000/favicon.ico", host: "localhost:3050", referrer: "http://localhost:3050/" nginx_1 | 172.25.0.1 - - [08/Jul/2019:02:52:57 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://localhost:3050/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36" "-" Any help is appreciated.
Needed to amend the docker-compose.yml: the upstream services should expose their ports so that the nginx service can connect i.e.: api: expose: - '5000' client: expose: - '3000' the nginx service depends_on the upstream services: nginx: depends_on: - 'client' - 'api'
Docker nginx responds 403 if you are offline
Im running docker with nginx, PHP and MariaDb in my company. But if my laptop is offline or Im connected with vpn the nginx responds with an 403 error. Docker is starting normally. Do you have any idea why I get the 403 from nginx? Maybe Its because of the mounted drives? 2018/06/05 13:23:20 [error] 5#5: *3 directory index of "/var/www/html/" is forbidden, client: 172.21.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost" 172.21.0.1 - - [05/Jun/2018:13:23:20 +0000] "GET / HTTP/1.1" 403 572 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36" "-" Edit: I figured out that I cant mount the shared drives. I got an error that the firewall blocks it.