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

Nginx fails to reload due to long server name #632

Closed
Tracked by #612
kate-osborn opened this issue May 9, 2023 · 2 comments · Fixed by #651
Closed
Tracked by #612

Nginx fails to reload due to long server name #632

kate-osborn opened this issue May 9, 2023 · 2 comments · Fixed by #651
Assignees
Labels
area/nginx-configuration Relates to nginx configuration bug Something isn't working refined Requirements are refined and the issue is ready to be implemented.
Milestone

Comments

@kate-osborn
Copy link
Contributor

Describe the bug
Nginx fails to reload with the following error message:

nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 64

To Reproduce
Steps to reproduce the behavior:

  1. Deploy NKG
  2. Create the cafe app:
  3. Apply the following manifest:
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
  name: gateway
  labels:
    domain: k8s-gateway.nginx.org
spec:
  gatewayClassName: nginx
  listeners:
  - name: http
    port: 80
    protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: coffee
spec:
  parentRefs:
  - name: gateway
    sectionName: http
  hostnames:
  - "abcdefghijklmn.too.long.server.name.example.org" // 47 characters seems to be the limit
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /coffee
    backendRefs:
    - name: coffee
      port: 80
  1. Get the logs of the nginx container: kubectl logs -n nginx-gateway <nginx-gateway-pod> -c nginx -- nginx -T
    Look for the following error message:
2023/05/09 15:22:56 [emerg] 41#41: could not build server_names_hash, you should increase server_names_hash_bucket_size: 64

Expected behavior
Nginx should reload successfully and the route should be configured.

Your environment

  • Version of the NGINX Kubernetes Gateway: main, commit: d62cf56
  • Version of Kubernetes: 1.26
  • Kubernetes platform (e.g. Mini-kube or GCP): kind
@kate-osborn kate-osborn added the bug Something isn't working label May 9, 2023
@saiyam1814
Copy link

thanks for creating this :)

@ja20222 ja20222 added this to the v0.4.0 milestone May 9, 2023
@ja20222 ja20222 added refined Requirements are refined and the issue is ready to be implemented. area/nginx-configuration Relates to nginx configuration labels May 9, 2023
@kate-osborn
Copy link
Contributor Author

kate-osborn commented May 9, 2023

Discussed as a team today and decided to fix this by increasing the default server_names_hash_bucket_size to 256 and server_names_hash_max_size to 1024. NGINX Ingress Controller uses these defaults, which should work in most cases.

In a later release, we can make these values configurable or even calculate them based on the length of the server name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/nginx-configuration Relates to nginx configuration bug Something isn't working refined Requirements are refined and the issue is ready to be implemented.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants