Nginx keeps reopening logs - nginx

Here are some informations about nginx running on the cluster:
nginx version: nginx/1.6.0
built by gcc 3.4.5 20051201 (Red Hat 3.4.5-2)
TLS SNI support disabled
configure arguments: --prefix=/home/work/local/nginx --with-http_ssl_module --with-http_realip_module --with-pcre=/home/work/download/pcre-8.35 --with-pcre-jit
The question is that why the Nginx keeps reopening logs about every five minutes? I have checked all the CRON tasks, strangely, there is no CRON which will send reopen signal to Nginx passively.
These are some logs where i tail the error.log of Nginx
2015/08/18 15:42:20 [notice] 17496#0: signal 10 (SIGUSR1) received, reopening logs
2015/08/18 15:42:20 [notice] 17496#0: reopening logs
2015/08/18 15:42:20 [notice] 17497#0: reopening logs
2015/08/18 15:42:20 [notice] 17498#0: reopening logs
2015/08/18 15:42:20 [notice] 17500#0: reopening logs
2015/08/18 15:42:20 [notice] 17503#0: reopening logs
2015/08/18 15:42:20 [notice] 17501#0: reopening logs
2015/08/18 15:42:20 [notice] 17505#0: reopening logs
2015/08/18 15:42:20 [notice] 17504#0: reopening logs
2015/08/18 15:42:20 [notice] 17512#0: reopening logs
2015/08/18 15:42:20 [notice] 17515#0: reopening logs
2015/08/18 15:42:20 [notice] 17509#0: reopening logs
2015/08/18 15:42:20 [notice] 17506#0: reopening logs
2015/08/18 15:42:20 [notice] 17517#0: reopening logs
2015/08/18 15:42:20 [notice] 17507#0: reopening logs
2015/08/18 15:42:20 [notice] 17521#0: reopening logs
2015/08/18 15:42:20 [notice] 17519#0: reopening logs
2015/08/18 15:42:20 [notice] 17511#0: reopening logs
2015/08/18 15:42:20 [notice] 17518#0: reopening logs
2015/08/18 15:42:20 [notice] 17513#0: reopening logs
2015/08/18 15:42:20 [notice] 17510#0: reopening logs
2015/08/18 15:42:20 [notice] 17520#0: reopening logs
2015/08/18 15:47:21 [notice] 17496#0: signal 10 (SIGUSR1) received, reopening logs
2015/08/18 15:47:21 [notice] 17496#0: reopening logs
2015/08/18 15:47:21 [notice] 17498#0: reopening logs
2015/08/18 15:47:21 [notice] 17497#0: reopening logs
2015/08/18 15:47:21 [notice] 17504#0: reopening logs
2015/08/18 15:47:21 [notice] 17503#0: reopening logs
2015/08/18 15:47:21 [notice] 17501#0: reopening logs
2015/08/18 15:47:21 [notice] 17500#0: reopening logs
2015/08/18 15:47:21 [notice] 17518#0: reopening logs
2015/08/18 15:47:21 [notice] 17505#0: reopening logs
2015/08/18 15:47:21 [notice] 17521#0: reopening logs
2015/08/18 15:47:21 [notice] 17520#0: reopening logs
2015/08/18 15:47:21 [notice] 17519#0: reopening logs
2015/08/18 15:47:21 [notice] 17507#0: reopening logs
2015/08/18 15:47:21 [notice] 17509#0: reopening logs
2015/08/18 15:47:21 [notice] 17517#0: reopening logs
2015/08/18 15:47:21 [notice] 17506#0: reopening logs
2015/08/18 15:47:21 [notice] 17515#0: reopening logs
2015/08/18 15:47:21 [notice] 17513#0: reopening logs
2015/08/18 15:47:21 [notice] 17511#0: reopening logs
2015/08/18 15:47:21 [notice] 17512#0: reopening logs
2015/08/18 15:47:21 [notice] 17510#0: reopening logs
Grateful for your answering!

signal 10 (SIGUSR1) received + http://article.gmane.org/gmane.comp.web.nginx.english/181 -> means something triggers log rotating... Nginx is not supporting that itself. Please see if you have logrotate running if so - please verify configuration.

Related

Kubernetes Nginx-Ingress Host-Based Routing works, while Path Based Routing doesn't work

I am running a 2-node K8s cluster on OVH Bare Metal Servers. I've set up MetalLB and Nginx-Ingress.The 2 servers both have public IPs and are not in the same network segment. I've used one of the IPs as the entrypoint for the LB. The deployments I created 3 nginx containers & services to test the forwarding.
When I use host based routing, the endpoints are reachable via the internet, but when I use path based forwarding, only the / path is reachable. For the rest, I get the default backend.
My host based Ingress resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-resource-2
spec:
ingressClassName: nginx
rules:
- host: nginx.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-deploy-main
port:
number: 80
- host: blue.nginx.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-deploy-blue
port:
number: 80
- host: green.nginx.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-deploy-green
port:
number: 80
The path based Ingress resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-resource-3
spec:
ingressClassName: nginx
rules:
- host: nginx.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx
port:
number: 80
- path: /blue
pathType: Prefix
backend:
service:
name: nginx-deploy-blue
port:
number: 80
- path: /green
pathType: Prefix
backend:
service:
name: nginx-deploy-green
port:
number: 80
The endpoints are all reachable in both cases
# kubectl describe ing ingress-resource-2
Name: ingress-resource-2
Labels: <none>
Namespace: default
Address:
Ingress Class: nginx
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
nginx.example.com
/ nginx:80 (192.168.107.4:80)
blue.nginx.example.com
/ nginx-deploy-blue:80 (192.168.164.212:80)
green.nginx.example.com
/ nginx-deploy-green:80 (192.168.164.213:80)
Annotations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal AddedOrUpdated 13m nginx-ingress-controller Configuration for default/ingress-resource-2 was added or updated
# kubectl describe ing ingress-resource-3
Name: ingress-resource-3
Labels: <none>
Namespace: default
Address:
Ingress Class: nginx
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
nginx.example.com
/ nginx:80 (192.168.107.4:80)
/blue nginx-deploy-blue:80 (192.168.164.212:80)
/green nginx-deploy-green:80 (192.168.164.213:80)
Annotations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal AddedOrUpdated 109s nginx-ingress-controller Configuration for default/ingress-resource-3 was added or updated
Getting the Nginx-Ingress logs:
# kubectl -n nginx-ingress logs pod/nginx-ingress-6947fb84d4-m9gkk
W0803 17:00:48.516628 1 flags.go:273] Ignoring unhandled arguments: []
I0803 17:00:48.516688 1 flags.go:190] Starting NGINX Ingress Controller Version=2.3.0 PlusFlag=false
I0803 17:00:48.516692 1 flags.go:191] Commit=979db22d8065b22fedb410c9b9c5875cf0a6dc66 Date=2022-07-12T08:51:24Z DirtyState=false Arch=linux/amd64 Go=go1.18.3
I0803 17:00:48.527699 1 main.go:210] Kubernetes version: 1.24.3
I0803 17:00:48.531079 1 main.go:326] Using nginx version: nginx/1.23.0
2022/08/03 17:00:48 [notice] 26#26: using the "epoll" event method
2022/08/03 17:00:48 [notice] 26#26: nginx/1.23.0
2022/08/03 17:00:48 [notice] 26#26: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
2022/08/03 17:00:48 [notice] 26#26: OS: Linux 5.15.0-41-generic
2022/08/03 17:00:48 [notice] 26#26: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2022/08/03 17:00:48 [notice] 26#26: start worker processes
2022/08/03 17:00:48 [notice] 26#26: start worker process 27
2022/08/03 17:00:48 [notice] 26#26: start worker process 28
2022/08/03 17:00:48 [notice] 26#26: start worker process 29
2022/08/03 17:00:48 [notice] 26#26: start worker process 30
2022/08/03 17:00:48 [notice] 26#26: start worker process 31
2022/08/03 17:00:48 [notice] 26#26: start worker process 32
2022/08/03 17:00:48 [notice] 26#26: start worker process 33
2022/08/03 17:00:48 [notice] 26#26: start worker process 34
I0803 17:00:48.543403 1 listener.go:54] Starting Prometheus listener on: :9113/metrics
2022/08/03 17:00:48 [notice] 26#26: start worker process 35
2022/08/03 17:00:48 [notice] 26#26: start worker process 37
I0803 17:00:48.543712 1 leaderelection.go:248] attempting to acquire leader lease nginx-ingress/nginx-ingress-leader-election...
2022/08/03 17:00:48 [notice] 26#26: start worker process 38
...
2022/08/03 17:00:48 [notice] 26#26: start worker process 86
I0803 17:00:48.645253 1 event.go:285] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"delivery-ingress", UID:"23f93b2d-c3c8-48eb-a2a1-e2ce0453677f", APIVersion:"networking.k8s.io/v1", ResourceVersion:"1527358", FieldPath:""}): type: 'Normal' reason: 'AddedOrUpdated' Configuration for default/delivery-ingress was added or updated
I0803 17:00:48.645512 1 event.go:285] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"ingress-resource-3", UID:"66ed1c4b-54ae-4880-bf08-49029a93e365", APIVersion:"networking.k8s.io/v1", ResourceVersion:"1622747", FieldPath:""}): type: 'Normal' reason: 'AddedOrUpdated' Configuration for default/ingress-resource-3 was added or updated
I0803 17:00:48.646550 1 event.go:285] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"ingress-resource-3", UID:"66ed1c4b-54ae-4880-bf08-49029a93e365", APIVersion:"networking.k8s.io/v1", ResourceVersion:"1622747", FieldPath:""}): type: 'Normal' reason: 'AddedOrUpdated' Configuration for default/ingress-resource-3 was added or updated
I0803 17:00:48.646629 1 event.go:285] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"delivery-ingress", UID:"23f93b2d-c3c8-48eb-a2a1-e2ce0453677f", APIVersion:"networking.k8s.io/v1", ResourceVersion:"1527358", FieldPath:""}): type: 'Normal' reason: 'AddedOrUpdated' Configuration for default/delivery-ingress was added or updated
I0803 17:00:48.646810 1 event.go:285] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"ingress-resource-3", UID:"66ed1c4b-54ae-4880-bf08-49029a93e365", APIVersion:"networking.k8s.io/v1", ResourceVersion:"1622747", FieldPath:""}): type: 'Normal' reason: 'AddedOrUpdated' Configuration for default/ingress-resource-3 was added or updated
I0803 17:00:48.646969 1 event.go:285] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"ingress-resource-3", UID:"66ed1c4b-54ae-4880-bf08-49029a93e365", APIVersion:"networking.k8s.io/v1", ResourceVersion:"1622747", FieldPath:""}): type: 'Normal' reason: 'AddedOrUpdated' Configuration for default/ingress-resource-3 was added or updated
I0803 17:00:48.647259 1 event.go:285] Event(v1.ObjectReference{Kind:"Secret", Namespace:"nginx-ingress", Name:"default-server-secret", UID:"d8271053-2785-408f-b87b-88b9bb9fc488", APIVersion:"v1", ResourceVersion:"1612716", FieldPath:""}): type: 'Normal' reason: 'Updated' the special Secret nginx-ingress/default-server-secret was updated
2022/08/03 17:00:48 [notice] 26#26: signal 1 (SIGHUP) received from 88, reconfiguring
2022/08/03 17:00:48 [notice] 26#26: reconfiguring
2022/08/03 17:00:48 [notice] 26#26: using the "epoll" event method
2022/08/03 17:00:48 [notice] 26#26: start worker processes
2022/08/03 17:00:48 [notice] 26#26: start worker process 89
2022/08/03 17:00:48 [notice] 26#26: start worker process 90
...
2022/08/03 17:00:48 [notice] 26#26: start worker process 136
2022/08/03 17:00:48 [notice] 27#27: gracefully shutting down
2022/08/03 17:00:48 [notice] 27#27: exiting
2022/08/03 17:00:48 [notice] 35#35: gracefully shutting down
2022/08/03 17:00:48 [notice] 31#31: exiting
2022/08/03 17:00:48 [notice] 38#38: gracefully shutting down
2022/08/03 17:00:48 [notice] 32#32: exiting
2022/08/03 17:00:48 [notice] 30#30: exiting
2022/08/03 17:00:48 [notice] 40#40: gracefully shutting down
2022/08/03 17:00:48 [notice] 35#35: exiting
2022/08/03 17:00:48 [notice] 45#45: gracefully shutting down
2022/08/03 17:00:48 [notice] 40#40: exiting
2022/08/03 17:00:48 [notice] 48#48: gracefully shutting down
2022/08/03 17:00:48 [notice] 47#47: exiting
2022/08/03 17:00:48 [notice] 57#57: gracefully shutting down
2022/08/03 17:00:48 [notice] 52#52: exiting
2022/08/03 17:00:48 [notice] 55#55: gracefully shutting down
2022/08/03 17:00:48 [notice] 55#55: exiting
2022/08/03 17:00:48 [notice] 51#51: gracefully shutting down
2022/08/03 17:00:48 [notice] 51#51: exiting
2022/08/03 17:00:48 [notice] 31#31: exit
2022/08/03 17:00:48 [notice] 34#34: gracefully shutting down
2022/08/03 17:00:48 [notice] 34#34: exiting
2022/08/03 17:00:48 [notice] 41#41: exiting
2022/08/03 17:00:48 [notice] 49#49: gracefully shutting down
....
2022/08/03 17:00:48 [notice] 49#49: exiting
2022/08/03 17:00:48 [notice] 57#57: exit
.....
2022/08/03 17:00:48 [notice] 43#43: exit
2022/08/03 17:00:48 [notice] 58#58: gracefully shutting down
2022/08/03 17:00:48 [notice] 38#38: exiting
2022/08/03 17:00:48 [notice] 53#53: gracefully shutting down
2022/08/03 17:00:48 [notice] 48#48: exiting
2022/08/03 17:00:48 [notice] 59#59: gracefully shutting down
2022/08/03 17:00:48 [notice] 58#58: exiting
2022/08/03 17:00:48 [notice] 62#62: gracefully shutting down
2022/08/03 17:00:48 [notice] 60#60: gracefully shutting down
2022/08/03 17:00:48 [notice] 53#53: exiting
2022/08/03 17:00:48 [notice] 61#61: gracefully shutting down
2022/08/03 17:00:48 [notice] 63#63: gracefully shutting down
2022/08/03 17:00:48 [notice] 64#64: gracefully shutting down
2022/08/03 17:00:48 [notice] 59#59: exiting
2022/08/03 17:00:48 [notice] 65#65: gracefully shutting down
2022/08/03 17:00:48 [notice] 62#62: exiting
2022/08/03 17:00:48 [notice] 60#60: exiting
2022/08/03 17:00:48 [notice] 66#66: gracefully shutting down
2022/08/03 17:00:48 [notice] 67#67: gracefully shutting down
2022/08/03 17:00:48 [notice] 63#63: exiting
2022/08/03 17:00:48 [notice] 68#68: gracefully shutting down
2022/08/03 17:00:48 [notice] 64#64: exiting
2022/08/03 17:00:48 [notice] 61#61: exiting
2022/08/03 17:00:48 [notice] 69#69: gracefully shutting down
2022/08/03 17:00:48 [notice] 65#65: exiting
2022/08/03 17:00:48 [notice] 66#66: exiting
2022/08/03 17:00:48 [notice] 71#71: gracefully shutting down
2022/08/03 17:00:48 [notice] 70#70: gracefully shutting down
2022/08/03 17:00:48 [notice] 67#67: exiting
...
2022/08/03 17:00:48 [notice] 65#65: exit
2022/08/03 17:00:48 [notice] 73#73: gracefully shutting down
...
2022/08/03 17:00:48 [notice] 74#74: exiting
2022/08/03 17:00:48 [notice] 83#83: gracefully shutting down
2022/08/03 17:00:48 [notice] 72#72: exiting
2022/08/03 17:00:48 [notice] 77#77: gracefully shutting down
2022/08/03 17:00:48 [notice] 77#77: exiting
2022/08/03 17:00:48 [notice] 77#77: exit
I0803 17:00:48.780547 1 event.go:285] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"nginx-ingress", Name:"nginx-config", UID:"961b1b89-3765-4eb8-9f5f-cfd8212012a8", APIVersion:"v1", ResourceVersion:"1612730", FieldPath:""}): type: 'Normal' reason: 'Updated' Configuration from nginx-ingress/nginx-config was updated
I0803 17:00:48.780573 1 event.go:285] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"delivery-ingress", UID:"23f93b2d-c3c8-48eb-a2a1-e2ce0453677f", APIVersion:"networking.k8s.io/v1", ResourceVersion:"1527358", FieldPath:""}): type: 'Normal' reason: 'AddedOrUpdated' Configuration for default/delivery-ingress was added or updated
I0803 17:00:48.780585 1 event.go:285] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"ingress-resource-3", UID:"66ed1c4b-54ae-4880-bf08-49029a93e365", APIVersion:"networking.k8s.io/v1", ResourceVersion:"1622747", FieldPath:""}): type: 'Normal' reason: 'AddedOrUpdated' Configuration for default/ingress-resource-3 was added or updated
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 72
2022/08/03 17:00:48 [notice] 26#26: worker process 72 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 30
2022/08/03 17:00:48 [notice] 26#26: worker process 30 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 35 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 77 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 73
2022/08/03 17:00:48 [notice] 26#26: worker process 73 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 37
2022/08/03 17:00:48 [notice] 26#26: worker process 29 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 32 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 37 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 38 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 41 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 47 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 49 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 63 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 64 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 75 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 47
2022/08/03 17:00:48 [notice] 26#26: worker process 34 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 43 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 48 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 53 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 54 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 59 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 61 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 66 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 55
2022/08/03 17:00:48 [notice] 26#26: worker process 50 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 55 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 83
2022/08/03 17:00:48 [notice] 26#26: worker process 28 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 31 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 42 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 51 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 52 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 56 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 62 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 68 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 71 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 83 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 33
2022/08/03 17:00:48 [notice] 26#26: worker process 33 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 58
2022/08/03 17:00:48 [notice] 26#26: worker process 58 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 57
2022/08/03 17:00:48 [notice] 26#26: worker process 27 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 57 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
2022/08/03 17:00:48 [notice] 26#26: signal 17 (SIGCHLD) received from 40
2022/08/03 17:00:48 [notice] 26#26: worker process 40 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 45 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 60 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 65 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 67 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 69 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 70 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 74 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: worker process 86 exited with code 0
2022/08/03 17:00:48 [notice] 26#26: signal 29 (SIGIO) received
I'm not sure what the issue is, and I can't figure out why it's working when I use different hosts, and not working when I try to use different paths.
I thought it could be resource limits, but I only have the requests, no limits. There is already a default IngressClass
I installed the ingress controller via manifests following the steps here
Update: To add the deployments running in the cluster.
# nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
run: nginx-main
template:
metadata:
labels:
run: nginx-main
spec:
containers:
- image: nginx
name: nginx
# nginx-deploy-green.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: nginx
name: nginx-deploy-green
spec:
replicas: 1
selector:
matchLabels:
run: nginx-green
template:
metadata:
labels:
run: nginx-green
spec:
volumes:
- name: webdata
emptyDir: {}
initContainers:
- name: web-content
image: busybox
volumeMounts:
- name: webdata
mountPath: "/webdata"
command: ["/bin/sh", "-c", 'echo "<h1>I am <font color=green>GREEN</font></h1>" > /webdata/index.html']
containers:
- image: nginx
name: nginx
volumeMounts:
- name: webdata
mountPath: "/usr/share/nginx/html"
# nginx-deploy-blue.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: nginx
name: nginx-deploy-blue
spec:
replicas: 1
selector:
matchLabels:
run: nginx-blue
template:
metadata:
labels:
run: nginx-blue
spec:
volumes:
- name: webdata
emptyDir: {}
initContainers:
- name: web-content
image: busybox
volumeMounts:
- name: webdata
mountPath: "/webdata"
command: ["/bin/sh", "-c", 'echo "<h1>I am <font color=blue>BLUE</font></h1>" > /webdata/index.html']
containers:
- image: nginx
name: nginx
volumeMounts:
- name: webdata
mountPath: "/usr/share/nginx/html"
I believe the reason is that the nginx service you have deployed for "blue" and "green" deployments are not serving anything on the /blue and /green endpoints. You need to create these endpoints inside nginx so that they become valid. Your ingress objects appear fine.
That's also why you see / working in all cases since by default nginx is hosting a web page on the path / but not on the paths /blue and /green. Simply creating the respective endpoints in your services for nginx should fix the problem.
Based on the comments from zer0 answered, try:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-resource-3
annotations:
nginx.ingress.kubernetes.io/rewrite-target: / # <-- add
spec:
ingressClassName: nginx
...
Page with different font color should response when your browse to http://nginx.example.com/blue or green
I'm not sure if the issue was in how I had deployed the NGINX Ingress Controller, but I tried using the Ingress-nginx controller, and the ingress objects work perfectly well.
I will still try again with the NGINX Ingress Controller just to be sure, but for now the routing is behaving as expected with the other ingress controller.
Thanks for your help guys. I will update if I get it to work with the original Ingress Controller.

Running nginx on gcp with docker-compose

I would like to run (to test if it works) nginx on my gcp vm instance with docker-compose.
My docker-compose.yml looks like:
version: '3'
services:
nginx:
image: nginx:latest
container_name: webserver
restart: unless-stopped
ports:
- 8080:8080
On my gcp I allow for http and https trafics.
When I start docker-compose I get:
Starting webserver ... done
Attaching to webserver
webserver | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
webserver | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
webserver | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
webserver | 10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
webserver | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
webserver | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
webserver | /docker-entrypoint.sh: Configuration complete; ready for start up
webserver | 2022/04/24 11:48:14 [notice] 1#1: using the "epoll" event method
webserver | 2022/04/24 11:48:14 [notice] 1#1: nginx/1.21.6
webserver | 2022/04/24 11:48:14 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
webserver | 2022/04/24 11:48:14 [notice] 1#1: OS: Linux 4.19.0-20-cloud-amd64
webserver | 2022/04/24 11:48:14 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
webserver | 2022/04/24 11:48:14 [notice] 1#1: start worker processes
webserver | 2022/04/24 11:48:14 [notice] 1#1: start worker process 26
And when I visit my vm's external ip: EXTERNAL_IP:8080 in web browser I don't get any information about nginx installed. What else do I need to make sure nginx works properly?
EDIT: Problem solved. From weird reson, nginx wasn't starting on 8080 port but on 49154

Nginx doesn't start

Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: timeout) since Tue 2020-03-10 16:35:07 UTC; 9min ago
Process: 5027 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 5023 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 5021 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 25158 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nginx.service
├─5029 nginx: master process /usr/sbin/nginx
├─5030 nginx: worker process
├─5031 nginx: worker process
├─5032 nginx: worker process
├─5033 nginx: worker process
├─5034 nginx: worker process
├─5035 nginx: worker process
├─5036 nginx: worker process
├─5037 nginx: worker process
├─5038 nginx: worker process
├─5039 nginx: worker process
├─5040 nginx: worker process
├─5041 nginx: worker process
├─5042 nginx: worker process
├─5043 nginx: worker process
├─5044 nginx: worker process
├─5045 nginx: worker process
├─5046 nginx: worker process
├─5047 nginx: worker process
├─5048 nginx: worker process
├─5049 nginx: worker process
├─5050 nginx: worker process
├─5051 nginx: worker process
├─5052 nginx: worker process
└─5053 nginx: worker process
Mar 10 16:33:37 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: Starting The nginx HTTP and reverse proxy server...
Mar 10 16:33:37 ip-172-31-36-184.us-west-2.compute.internal nginx[5023]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Mar 10 16:33:37 ip-172-31-36-184.us-west-2.compute.internal nginx[5023]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Mar 10 16:33:37 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: PID file /run/nginx.pid not readable (yet?) after start.
Mar 10 16:35:07 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: nginx.service start operation timed out. Terminating.
Mar 10 16:35:07 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Mar 10 16:35:07 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: Unit nginx.service entered failed state.
Mar 10 16:35:07 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: nginx.service failed.
I have such error and I don't know how to solve this problem.
I did all configurations but it still doesn't run.
This is the root cause of the issue
PID file /run/nginx.pid not readable (yet?) after start.
you may need to start the NGINX server with root privileges or update the service file to have the pid file in another location that is readable by Nginx
PIDFile=/usr/local/nginx/logs/nginx.pid

NGINX Server Is Not Starting [ Closed ]

My NGINX server have stopped and it is generating error.
I am using Ubantu 16.04 and my app deploye at Digital Ocean Server.
When I run the following colde sudo systemctl start nginx It is giving following output:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
Output of $ nginx -t is:
nginx: [emerg] BIO_new_file("/root/bitradiology.chained.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/root/bitradiology.chained.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed
I checked the status with $ sudo systemctl status nginx
output is:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-08-21 11:01:51 UTC; 1min 50s ago
Process: 2085 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=2)
Process: 2420 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 2462 (code=exited, status=0/SUCCESS)
Aug 21 11:01:51 ubuntu-512mb-nyc3-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 21 11:01:51 ubuntu-512mb-nyc3-01 nginx[2420]: nginx: [emerg] BIO_new_file("/root/bitradiology.chained.crt") failed (SSL: error:02001002:system library:fopen:No such
Aug 21 11:01:51 ubuntu-512mb-nyc3-01 nginx[2420]: nginx: configuration file /etc/nginx/nginx.conf test failed
Aug 21 11:01:51 ubuntu-512mb-nyc3-01 systemd[1]: nginx.service: Control process exited, code=exited status=1
Aug 21 11:01:51 ubuntu-512mb-nyc3-01 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Aug 21 11:01:51 ubuntu-512mb-nyc3-01 systemd[1]: nginx.service: Unit entered failed state.
Aug 21 11:01:51 ubuntu-512mb-nyc3-01 systemd[1]: nginx.service: Failed with result 'exit-code'.
lines 1-14/14 (END)
How to fix this problem
I found this bitradiology.chained.crt file into the cd /usr directory.
Then go to the following directory cd /etc/nginx/sites-enabled and open the default file
sudo nano default
I edited this file and replaced /root/ by /usr/
/root/bitradiology.chained.crt by /usr/bitradiology.chained.crt
I run the nginx config test first:
nginx -t
after the test ran successful, I can restart the service
/etc/init.d/nginx restart
NGINX has been started and my app is running right now.
Thanks!!!
Check your ssl_certificate instructions in your config files.
Nginx is clearly saying it can't find one of the files specified:
fopen:No such file or
directory:fopen('/root/bitradiology.chained.crt','r')

I cannot connect with the server ngnix: Unable to connect

I dont get any error message in
/var/log/nginx/error.log
I make sudo service nginx restart OK
My code in /etc/nginx/nginx.conf is => https://codeshare.io/q9Nr3
My code in /etc/nginx/sites-available/default is => https://codeshare.io/Rm7wP
When I executed my code in nginx -s reload
miguel#127:/$ nginx -s reload
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2016/01/29 21:02:32 [warn] 3471#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2016/01/29 21:02:32 [notice] 3471#0: signal process started
2016/01/29 21:02:32 [alert] 3471#0: kill(1154, 1) failed (1: Operation not permitted)
I put in my terminal sudo chmod -R 755 /var/log/nginx, but I dont get permissions

Resources