Apparmor profile needed

Please use this template for troubleshooting questions.

My issue:

What would you like to discuss?

Websites explaining nginx apparmor tells different profile. What is the correct profile so that I can use?

Here’s my current profile for public-facing webserver listen 0.0.0.0:443:

abi <abi/4.0>,

include <tunables/global>

/usr/sbin/nginx flags=(complain) {
  include <abstractions/base>
  include <abstractions/nameservice>

  capability dac_override,
  capability net_bind_service,
  capability setgid,
  capability setuid,

  /etc/nginx/** r,
  /run/nginx.pid rwk,
  /usr/sbin/nginx mr,
  /usr/share/nginx/** r,
  /var/log/nginx/** rw,

  /var/lib/nginx/ssl_certs/** r,
  /var/lib/nginx/cache/ rw,
  /var/lib/nginx/cache/** rw,

  /var/www/** r,

  /etc/group r,
  /etc/nsswitch.conf r,
  /etc/passwd r,

}

How I encountered the problem:

Solutions I’ve tried:

Version of NGINX or NGINX adjacent software (e.g. NGINX Gateway Fabric):

Deployment environment:

Minimal NGINX config to reproduce your issue (preferably running on NGINX Playground | tech-playground.com for ease of debugging, and if not as a code block): (Tip → Run nginx -T to print your entire NGINX config to your terminal.)

NGINX access/error log: (Tip → You can usually find the logs in the /var/log/nginx directory.)