Skip to content

nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead #74

@replete

Description

@replete

Main Issue:

web-1  | nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead

This deprecation warning can be fixed by moving http2 into a new directive like so:

server {
    listen 80 reuseport default_server;
    listen [::]:80 reuseport default_server;
    listen 443 ssl reuseport;
    listen [::]:443 ssl reuseport;

    http2 on;
	
	# ...

Secondary query:

Also can you please tell us how best to use these images with custom nginx configuration? This is my workaround for custom nginx configuration:

Currently, I copy the nginx config from the running container:
docker cp $(docker compose -f ../docker-compose.yml ps -q web):/etc/nginx ../nginx-dev-config

And then mount the files individually with volumes in my docker-compose.yml:

    volumes:
      # App
      - ./statamic:/var/www/html
      # Dev SSL keys (npm run devcerts in /statamic)
      - ./dev.crt:/etc/ssl/site/server.crt:ro
      - ./dev.key:/etc/ssl/site/server.key:ro
      # Nginx dev config
      - ./nginx-dev-config/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx-dev-config/sites-enabled/00-default.conf:/etc/nginx/sites-enabled/00-default.conf:ro
      - ./nginx-dev-config/fastcgi.conf:/etc/nginx/fast-cgi.conf:ro
      - ./nginx-dev-config/custom.d/common.conf:/etc/nginx/custom.d/common.conf:ro

But this generates these sed errors in the container:

web-1  | sed: can't move '/etc/nginx/sites-enabled/00-default.confgdAIiC' to '/etc/nginx/sites-enabled/00-default.conf': Resource busy
web-1  | sed: can't move '/etc/nginx/nginx.confBAdMAD' to '/etc/nginx/nginx.conf': Resource busy
web-1  | sed: can't move '/etc/nginx/nginx.confidBlHD' to '/etc/nginx/nginx.conf': Resource busy
web-1  | nginx version: nginx/1.26.1
web-1  | sed: can't move '/etc/nginx/custom.d/common.confIfHmAE' to '/etc/nginx/custom.d/common.conf': Resource busy
web-1  | nginx: [warn] "ssl_stapling" ignored, issuer certificate not found for certificate "/etc/ssl/site/server.crt"
web-1  | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
web-1  | nginx: configuration file /etc/nginx/nginx.conf test is successful
web-1  | [12-Jul-2024 10:46:31] NOTICE: fpm is running, pid 381
web-1  | [12-Jul-2024 10:46:31] NOTICE: ready to handle connections
web-1  | nginx: [warn] "ssl_stapling" ignored, issuer certificate not found for certificate "/etc/ssl/site/server.crt"

This image is advertised as production ready, so could you help me understand how you would make custom nginx configurations, is it similar to this method? I would prefer to eliminate all warnings and errors from a production environment, you would expect to need custom nginx configuration in production.

Thank you once again for really excellent great work. Appreciate your last bugfix 🙌

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions