Nginx Ingress on Kubernetes Cluster - nginx

`I had a working Ingress controller version 1.0.0 (Bitnami). It stopped working one fine morning, and it appeared that the error was due to the version being depricated. Now I tried to upgrade this version, but started getting errors. I delete ingress and reinstalled it again, and this time from Bitnami repo which pulled the latest image. It is throwing errors. I created a new AKS cluster and installed ingress on it from the same repo, and it seems to work perfectly fine. Can somebody help me understand how this can be fixed please? I have over 120 services running on this cluster, and starting over would mean a lot of effort and time.
E0419 10:57:29.245933 1 queue.go:130] "requeuing" err="\n-------------------------------------------------------------------------------\nError: exit status 1\n2022/04/19 10:57:29 [warn] 25#25: the \"http2_max_field_size\" directive is obsolete, use the \"large_client_header_buffers\" directive instead in /tmp/nginx-cfg2573211911:143\nnginx: [warn] the \"http2_max_field_size\" directive is obsolete, use the \"large_client_header_buffers\" directive instead in /tmp/nginx-cfg2573211911:143\n2022/04/19 10:57:29 [warn] 25#25: the \"http2_max_header_size\" directive is obsolete, use the \"large_client_header_buffers\" directive instead in /tmp/nginx-cfg2573211911:144\nnginx: [warn] the \"http2_max_header_size\" directive is obsolete, use the \"large_client_header_buffers\" directive instead in /tmp/nginx-cfg2573211911:144\n2022/04/19 10:57:29 [warn] 25#25: the \"http2_max_requests\" directive is obsolete, use the \"keepalive_requests\" directive instead in /tmp/nginx-cfg2573211911:145\nnginx: [warn] the \"http2_max_requests\" directive is obsolete, use the \"keepalive_requests\" directive instead in /tmp/nginx-cfg2573211911:145\n2022/04/19 10:57:29 [emerg] 25#25: \"location\" directive is not allowed here in /tmp/nginx-cfg2573211911:783\nnginx: [emerg] \"location\" directive is not allowed here in /tmp/nginx-cfg2573211911:783\nnginx: configuration file /tmp/nginx-cfg2573211911 test failed\n\n-------------------------------------------------------------------------------\n" key="initial-sync"
I0419 10:57:29.246021 1 event.go:282] Event(v1.ObjectReference{Kind:"Pod", Namespace:"nginx-ingress", Name:"nginx-nginx-ingress-controller-5575846679-bjwkp", UID:"9e5641ae-345c-4d3c-a840-83c143f07fd3", APIVersion:"v1", ResourceVersion:"5932936", FieldPath:""}): type: 'Warning' reason: 'RELOAD' Error reloading NGINX:
-------------------------------------------------------------------------------
Error: exit status 1
2022/04/19 10:57:29 [warn] 25#25: the "http2_max_field_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /tmp/nginx-cfg2573211911:143
nginx: [warn] the "http2_max_field_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /tmp/nginx-cfg2573211911:143
2022/04/19 10:57:29 [warn] 25#25: the "http2_max_header_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /tmp/nginx-cfg2573211911:144
nginx: [warn] the "http2_max_header_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /tmp/nginx-cfg2573211911:144
2022/04/19 10:57:29 [warn] 25#25: the "http2_max_requests" directive is obsolete, use the "keepalive_requests" directive instead in /tmp/nginx-cfg2573211911:145
nginx: [warn] the "http2_max_requests" directive is obsolete, use the "keepalive_requests" directive instead in /tmp/nginx-cfg2573211911:145
2022/04/19 10:57:29 [emerg] 25#25: "location" directive is not allowed here in /tmp/nginx-cfg2573211911:783
nginx: [emerg] "location" directive is not allowed here in /tmp/nginx-cfg2573211911:783
nginx: configuration file /tmp/nginx-cfg2573211911 test failed

It turns out the problem was with the ingress class name "nginx". I re-deployed the ingress controller, this time with a values file and ingressclass name as dev-nginx and this seems to resolve the issue. I then had to delete the existing ingressClass and re-deploy ingress to fix the issue.
E0421 07:40:56.183407 7 main.go:122] Unexpected error searching IngressClass: ingressclasses.networking.k8s.io "nginx" is forbidden: User "system:serviceaccount:default:ingress-nginx" cannot get resource "ingressclasses" in API group "networking.k8s.io" at the cluster scope
W0421 07:40:56.183431 7 main.go:125] No IngressClass resource with name nginx found. Only annotation will be us

Related

Kong with OWASP ModSecurity optional configuration include

For customizing of ModSecurity configuration I have included to the modsecurity.conf following line:
Include /etc/modsecurity/*.conf
But without any conf file in the directory (usual case on my enviroment), a kong failing during startup
Error: could not prepare Kong prefix at /usr/local/kong: nginx
configuration is invalid (exit code 1): nginx: [emerg]
"modsecurity_rules_file" directive Rules error. File:
/usr/local/kong/modsecurity.conf. Line: 268. Column: 31.
/etc/modsecurity/.conf: Not able to open file. Looking at:
'/etc/modsecurity/.conf', '/etc/modsecurity/.conf',
'/usr/local/kong//etc/modsecurity/.conf',
'/usr/local/kong//etc/modsecurity/*.conf'. in
/usr/local/kong/nginx-kong.conf:69 nginx: configuration file
/usr/local/kong/nginx.conf test failed
IncludeOptional not supported by kong.
How I can solve the case with optional include?
Kong version 1.2.X

Nginx dynamic load balancing

How do I have to create my /etc/nginx/nginx.conf for using the REST-API? The Loadbalancing works fine, though. But creating an API endpoint does not function as I thought it should be.
When I try to start the service, it fails with this error message:
nginx: [emerg] unknown directive "api" in /etc/nginx/nginx.conf:27

SecContentInjection is not yet supported

I am getting below error when using ContentInjection rule
vi /etc/nginx/nginx.conf nginx -s reload 10:26:25 [notice] 118#118:
ModSecurity-nginx v1.0.0 10:26:25 [emerg] 118#118: "modsecurity_rules"
directive Rules error. File: <>.
Line: 1. Column: 16. SecContentInjection is not yet supported. in
/etc/nginx/nginx
rg] "modsecurity_rules" directive Rules error. File: <>. Line: 1. Column: 16. SecContentInjection is
not yet supported. in /etc/nginx/nginx.conf:66
It's not supported in libModSecurity 3.0. And I am not sure, it is impossible to bring this feature to nginx the way it used to work on Apache.

nginx: [emerg] "XXX" directive is duplicate in /etc/nginx/conf.d/XXX.conf:7

when doing
nginx -t
error message :
nginx: [emerg] "client_max_body_size" directive is duplicate in /etc/nginx/conf.d/proxy-settings.conf:7
Remove the second copy of the directive from file /etc/nginx/conf.d/proxy-settings.conf - at line 7.
actually i also defined "client_max_body_size" in /etc/nginx/sites-enabled/XXX.config, so the same variable "client_max_body_size" is duplicated in /etc/nginx/conf.d/proxy-settings.conf - that is the reason it is giving that error.
I resolved by removing the duplicate variable in /etc/nginx/conf.d/proxy-settings.conf :)

SPDY instead of HTTP2 on Nginx 1.10

I just upgrade a server and decide to install latest stable Nginx version, 1.10.
The problem is that I am getting the error bellow on images and js. I do not get this error on all images, and it is random error.
Failed to load resource: net::ERR_SPDY_PROTOCOL_ERROR
I try to use spdy on config but I get a warn and test failed.
nginx: [warn] invalid parameter "spdy": ngx_http_spdy_module was superseded by ngx_http_v2_module
Anyway to use SPDY until HTTP2 is more acceptable on Nginx 1.10? Looking for a simple fix that could be done only on Nginx conf.
I found this patch
https://blog.cloudflare.com/open-sourcing-our-nginx-http-2-spdy-code/
But yesterday I got less spdy errors. And I also had an error on my code when I upgrade server.

Resources