Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ingress-nginx controller crashes due to unknown directive "alias" when using global snippets. #11322

Closed
albgus opened this issue Apr 29, 2024 · 5 comments
Labels
kind/support Categorizes issue or PR as a support question. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@albgus
Copy link

albgus commented Apr 29, 2024

What happened:
In an attempt to find a workaround for
#9211 #8376 I have added the following snippets to the ingress-nginx configMap.

  http-snippet: |
    error_page 400 /_error/400.html;
    error_page 401 /_error/401.html;
    error_page 403 /_error/403.html;
    error_page 404 /_error/404.html;
    error_page 405 /_error/405.html;
    error_page 408 /_error/408.html;
    error_page 413 /_error/413.html;
    error_page 414 /_error/414.html;
    error_page 416 /_error/416.html;
    error_page 494 /_error/494.html;
    error_page 495 /_error/495.html;
    error_page 496 /_error/496.html;
    error_page 500 /_error/500.html;
    error_page 502 /_error/502.html;
    error_page 503 /_error/503.html;
    error_page 504 /_error/504.html;
  server-snippet: |
    location /_error/ {
        internal;
        client_max_body_size 0;
        alias /etc/nginx/error_pages;
    }

This results in ingress-nginx returning an error stating that the alias directive doesn't exist.

-------------------------------------------------------------------------------
E0429 07:40:57.625086       7 queue.go:131] "requeuing" err=<
	-------------------------------------------------------------------------------
	Error: exit status 1
	2024/04/29 07:40:57 [emerg] 41#41: unknown directive "alias" in /tmp/nginx/nginx-cfg3303928091:461
	nginx: [emerg] unknown directive "root" in /tmp/nginx/nginx-cfg3303928091:461
	nginx: configuration file /tmp/nginx/nginx-cfg3303928091 test failed
	-------------------------------------------------------------------------------

What you expected to happen:
As the alias and root directives are part of the nginx ngx_http_core_module I would have expected them to work.

NGINX Ingress controller version

-------------------------------------------------------------------------------
NGINX Ingress controller
  Release:       v1.10.0
  Build:         71f78d49f0a496c31d4c19f095469f3f23900f8a
  Repository:    https://github.com/kubernetes/ingress-nginx
  nginx version: nginx/1.25.3

-------------------------------------------------------------------------------

Kubernetes version (use kubectl version):

Client Version: v1.29.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.1

Environment:

  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools:
    • Please mention how/where was the cluster created like kubeadm/kops/minikube/kind etc.
  • Basic cluster related info:
    • kubectl version
    • kubectl get nodes -o wide

How was the ingress-nginx-controller installed:
Helm chart v4.10.0 (through ArgoCD)

values.yml
controller:
  kind: Deployment
  replicaCount: 2
  config:
    use-forwarded-headers: "true"
    proxy-real-ip-cidr: "10.160.20.0/24"
    log-format-upstream: >-
      $remote_addr - $remote_user [$time_iso8601] "$request" $status $body_bytes_sent
      "$http_referer" "$http_user_agent" $request_length $request_time
      [$namespace/$service_name:$service_port] [$proxy_alternative_upstream_name]
      $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id
    # Tweaks to allow large headers
    large-client-header-buffers: 8 64k
    client-header-buffer-size: 8k
    proxy-buffers-number: 16
    proxy-buffer-size: 32k
    server-snippet: |
      location /_error/ {
          internal;
          client_max_body_size 0;
          alias /etc/nginx/error_pages;
      }
    http-snippet: |
      error_page 400 /_error/400.html;
      error_page 401 /_error/401.html;
      error_page 403 /_error/403.html;
      error_page 404 /_error/404.html;
      error_page 405 /_error/405.html;
      error_page 408 /_error/408.html;
      error_page 413 /_error/413.html;
      error_page 414 /_error/414.html;
      error_page 416 /_error/416.html;
      error_page 494 /_error/494.html;
      error_page 495 /_error/495.html;
      error_page 496 /_error/496.html;
      error_page 500 /_error/500.html;
      error_page 502 /_error/502.html;
      error_page 503 /_error/503.html;
      error_page 504 /_error/504.html;
  allowSnippetAnnotations: true
  extraVolumes:
    - name: nginx-error-pages
      configMap:
        name: ingress-nginx-error-pages
  extraVolumeMounts:
    - name: nginx-error-pages
      mountPath: /etc/nginx/error_pages
  extraArgs:
    default-ssl-certificate: "ingress-nginx/staging-internal-default-tls"
  watchIngressWithoutClass: false
  ingressClassResource:
    name: internal-nginx
    enabled: true
    default: true
    controllerValue: "k8s.io/internal-nginx"
  ingressClass: internal-nginx
  podAnnotations:
    prometheus.io/scrape: true
    prometheus.io/port: 10254
  metrics:
    enabled: true
  service:
    type: NodePort
    nodePorts:
      http: 30080
      https: 30443
  resources:
    requests:
      cpu: 50m
      memory: 256Mi
    limits:
      memory: 256Mi
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
**How to reproduce this issue**:

Anything else we need to know:

@albgus albgus added the kind/bug Categorizes issue or PR as related to a bug. label Apr 29, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Apr 29, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@longwuyuan
Copy link
Contributor

/remove-kind bug
/kind support

Try the root directive https://nginx.org/en/docs/http/ngx_http_core_module.html#alias

The nginx directives you choose are not coded in the controller, just to state the obvious.

Please feel free to re-open the issue and add the details as asked in a new bug report template, in case you find problem in the controller itself.

/close

@k8s-ci-robot k8s-ci-robot added kind/support Categorizes issue or PR as a support question. and removed kind/bug Categorizes issue or PR as related to a bug. labels Apr 29, 2024
@k8s-ci-robot
Copy link
Contributor

@longwuyuan: Closing this issue.

In response to this:

/remove-kind bug
/kind support

Try the root directive https://nginx.org/en/docs/http/ngx_http_core_module.html#alias

The nginx directives you choose are not coded in the controller, just to state the obvious.

Please feel free to re-open the issue and add the details as asked in a new bug report template, in case you find problem in the controller itself.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@longwuyuan
Copy link
Contributor

Actually I was wrong earlier (or maybe not as you are using snippet.sorry not clear) It seems the project removed the support for both alias and root directive #8624

Example of a custom backend service with custom error pages https://kubernetes.github.io/ingress-nginx/examples/customization/custom-errors/

@albgus
Copy link
Author

albgus commented May 13, 2024

Ok, that is a bit unfortunate. As mentioned in my original issue the documented method doesn't work because it enforces overwriting all errors returned from the backend, which is not what I want. However perhaps it's possible to implement something similar to the included error handling with a custom backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
Development

No branches or pull requests

3 participants