If Nginx Proxy Manager 2.17 fails with nginx: [emerg] unknown "hsts_header" variable, the cause is that 2.17 no longer defines $hsts_header and one of your hosts uses it in its custom configuration. Rename that variable to $hsts_header_plain, or define it yourself in /data/nginx/custom/http_top.conf. The failure does not show up when you upgrade: nginx keeps working until the config of the last host created on the previous version is regenerated. I reproduced it on 22 November 2026 on arm64 Linux, with the 2.16.0, 2.17.0 and 2.17.1 images and three test hosts. There is a Spanish version of this guide.

Key takeaways

  • Nginx Proxy Manager 2.17.0 (12 November 2026) and 2.17.1 (19 November) generate $hsts_header_plain and $hsts_header_subdomains instead of $hsts_header.
  • After upgrading from 2.16.0, nginx -t passed and my three hosts kept answering, because the old files in /data/nginx/proxy_host/ still defined the variable.
  • The error appeared when I saved the last host that still carried the old map, and the admin panel showed nothing but Internal Error.
  • After a container restart, nginx did not start: ports 80 and 443 and the panel on port 81 were all down, and the log repeated the error 25 times in 30 s.
  • I tested two fixes: a compatibility map in http_top.conf, which brought nginx up without a restart, and replacing the variable with $hsts_header_plain.

Nginx: [emerg] unknown "hsts_header" variable in Nginx Proxy Manager 2.17

This is the literal message, as nginx -t returns it inside the container. In every command of this guide, npm is the container name: replace it with yours.

$ docker exec npm nginx -t
nginx: [emerg] unknown "hsts_header" variable
nginx: configuration file /etc/nginx/nginx.conf test failed

The message names neither the file nor the line, which makes the culprit harder to find. Depending on when it catches you, it shows up in three ways. The first is the container log (docker logs npm) after a restart, with the same pair of lines repeating forever:

❯ Starting nginx ...
nginx: [emerg] unknown "hsts_header" variable
❯ Starting nginx ...
nginx: [emerg] unknown "hsts_header" variable

The second is the admin panel: when you click Save on a host, the dialog stays open with the text Internal Error and nothing else. The third is the backend log, which writes an [Express] warning line with nginx: [emerg] unknown "hsts_header" variable every time someone saves a host. In that state docker ps lists the container as Up, so a monitor that only watches container status stays silent.

Why does it appear when you go from 2.16 to 2.17?

It appears because 2.17 renamed the variable that holds the value of the HTTP Strict Transport Security (HSTS) header. Up to 2.16.0, every host file started with this block, generated by the _hsts_map.conf template:

map $scheme $hsts_header {
    https   "max-age=63072000; preload";
}

With that map available, people copied into a host's custom configuration the same line the proxy itself uses. The common case is a custom location block, which in nginx does not inherit the headers of the server block once it declares one of its own. This is the block I used in the lab, taken from the example in issue 6059[1]:

location /api/ {
    add_header Strict-Transport-Security $hsts_header always;
    include conf.d/include/proxy.conf;
}

Version 2.17 generates two variables with new names, one for hosts without subdomains and one for hosts with HSTS Sub-domains switched on:

map $scheme $hsts_header_plain {
    https   "max-age=63072000; preload";
}
map $scheme $hsts_header_subdomains {
    https   "max-age=63072000;includeSubDomains; preload";
}

The change comes from pull request 5971[2], merged on 4 November 2026. It fixes a real bug: a map is global to nginx, so the subdomain switch of one host overrode all the others. Its author explains the rename in the commit message: "They get new names, so configs generated before this change, which still define $hsts_header, can't override them".

The templates stopped using $hsts_header, but nobody left an alias for people who used it by hand. Issue 6059 has asked for one since 19 November 2026 and is still open on 1 December. Pull request 6085, from 26 November, proposes bringing that alias back.

Why does it fail days later and not during the upgrade?

It does not fail during the upgrade because Nginx Proxy Manager does not regenerate host files at startup. The .conf files written by 2.16 stay in /data/nginx/proxy_host/ with their map $scheme $hsts_header, and as long as one of them remains, the variable exists for every host. With three hosts created on 2.16.0 (a.test, b.test and c.test, the second one with the location block above), I upgraded to 2.17.1. nginx -t passed, all three answered and they survived a restart.

The trouble starts as each host gets regenerated with the new template. A host is regenerated when you save it in the panel. According to the 2.17.1 backend code, the same happens when you enable it, when you edit an access list it uses and when you request a new certificate for its domain. I saved the hosts in two different orders and the outcome changed:

Save order What happened on 2.17.1
a.test, c.test and b.test last (the one that uses the variable) Saving b.test moved its file to 2.conf.err and that domain stopped answering. The other two and the panel stayed up, across a restart too
b.test, a.test and c.test last Saving c.test returned Internal Error in the panel, nginx -t started failing and the renamed file was 3.conf.err. After a restart nginx did not start

The second case is the dangerous one. The host that uses the variable regenerates without an error while another old file still defines it. When you save the last old host, the proxy blames that host, which has nothing wrong, and sets it aside as .conf.err. The configuration is still broken by the other one, so the reload fails.

Your domains keep answering from the configuration nginx holds in memory until the next restart of the container or the server.

On 2.17.0 the same sequence ended in the same nginx -t failure. If you have Watchtower updating your containers, 2.17 arrives on its own and the error can surface weeks later, with no visible link to the upgrade.

How to tell whether you are affected before it breaks

You are affected if any proxy host, redirection host or 404 host has $hsts_header in its custom configuration or in a custom location. A grep over /data/nginx is no use before regeneration, because every file written by 2.16 contains that variable. With the default SQLite database, this script looks for it in the records. Save it as find.py:

import sqlite3, re
db = sqlite3.connect("/data/database.sqlite")
for t in ("proxy_host", "redirection_host", "dead_host"):
    for r in db.execute(f"select * from {t} where is_deleted = 0"):
        if re.search(r"\$hsts_header(?!_)", " ".join(map(str, r))):
            print(t, r[0])

The 2.17.1 image ships Python 3.13.5, so it runs inside the container with nothing to install. In my lab it pointed at the right host, and empty output means there is nothing to change:

$ docker exec -i npm python3 < find.py
proxy_host 2

The number is the host identifier, the one shown as Proxy Host #2 in the three-dot menu of each row. I did not test the script with MySQL or PostgreSQL as the database. Once a host has been regenerated, this grep does find the file and the line:

$ docker exec npm sh -c \
    'grep -rn "hsts_header" /data/nginx | grep -v "hsts_header_"'
/data/nginx/proxy_host/2.conf:65:    add_header
    Strict-Transport-Security $hsts_header always;

The output is a single line; it is split here to fit.

Emergency fix: define $hsts_header in http_top.conf

If nginx no longer starts, the fastest way to bring it up is to give the variable back with a file of your own. Nginx Proxy Manager includes /data/nginx/custom/http_top.conf at the top of the http block, as its advanced configuration documentation[3] describes. docker exec works even with nginx down, because the container keeps running:

docker exec npm mkdir -p /data/nginx/custom
docker exec -i npm tee /data/nginx/custom/http_top.conf <<'EOF'
map $scheme $hsts_header {
    https   "max-age=63072000; preload";
}
EOF
docker exec npm nginx -t

The first command creates the folder, which does not exist on a fresh install. The second writes the map with the same value 2.16 generated, and the third validates the configuration. In my test nginx -t answered test is successful and nginx started without a container restart in under 8 s, because the supervisor was retrying it. The panel on port 81 came back, along with the two hosts that still had their file.

One step remains: the host set aside as .conf.err does not return until you save it again. Open that host in the panel and click Save; in my case 3.conf reappeared and c.test answered again. If you bind-mount the data folder from the server, the file is ./data/nginx/custom/http_top.conf next to your docker-compose.yml.

This fix has two limits. The value is the same for the whole proxy, which is the exact defect 2.17 fixed: if one host needs includeSubDomains, you cannot tell it apart here. You also depend on a file the interface never shows.

Permanent fix: replace $hsts_header with $hsts_header_plain

The clean fix is to use the new name in every custom configuration. With nginx up, open the host the script reported, go to the gear tab (Custom Nginx Configuration) and replace the variable. If the host has HSTS Sub-domains switched on, use $hsts_header_subdomains:

location /api/ {
    add_header Strict-Transport-Security $hsts_header_plain always;
    include conf.d/include/proxy.conf;
}

Do it after upgrading, not before: 2.16 does not define $hsts_header_plain and would fail the other way round. I tested it right after upgrading to 2.17.1, with the other two hosts still in the old format. The host saved without an error, then I saved the other two and everything kept answering after a restart.

If the panel is already down and you would rather not create http_top.conf, edit the generated file so nginx can start. This sed changed the line in my host 2:

docker exec npm sed -i \
  's/\$hsts_header always/$hsts_header_plain always/' \
  /data/nginx/proxy_host/2.conf
docker exec npm nginx -t

That edit lasts until the next save, because the panel rewrites the file from the database. With nginx up again, repeat the replacement in the gear tab and also save the host that was left as .conf.err. If you created http_top.conf as the emergency fix, delete it when you finish; I did, and nginx -t kept passing.

How to check that it is fixed

Three checks confirm the fix: the configuration validates, no file is set aside and the header is sent. The first is docker exec npm nginx -t with test is successful. The second is to list the host files and see that none ends in .err:

$ docker exec npm ls /data/nginx/proxy_host
1.conf
2.conf
3.conf

The third is to request a path of the custom block over HTTPS and look at the header. In the lab, with port 443 published on 32243 and a self-signed certificate, the response was this:

$ curl -sk -D - -o /dev/null \
    --resolve b.test:32243:127.0.0.1 https://b.test:32243/api/
HTTP/2 404
server: openresty
strict-transport-security: max-age=63072000; preload

The 404 belongs to the test backend, which has nothing at /api/; the last line is what counts. The 63,072,000 s are two years. Run the final test by restarting the container: if nginx starts and the log does not repeat the error, you are done.

Pitfalls I ran into while reproducing it

The first one is that the panel does not warn you. With 2.conf.err on disk and b.test not answering, the 2.17.1 list still showed that host as Online. The API does return nginx_online: false and the error text in the host's meta field, but the interface of this version does not display it. If a domain stops answering, look at the /data/nginx/proxy_host/ folder before you trust the Status column.

The second one is that the .conf.err file misleads. In the dangerous order, the host set aside is the last one you saved, not the one with the variable. Opening that .err file to look for a mistake leads nowhere; the grep from the earlier section finds it.

The third one is a race when checking. Right after saving a host, my first request to that domain returned the default page and the next one was correct. Wait a few seconds after each save before you accept a result.

The lookalike error: unknown "forward_host" variable

Version 2.17 has another error of the same shape: nginx: [emerg] unknown "forward_host" variable. Its cause is different. Issue 6043[4] describes it for 2.17.0, and the 2.17.1 release notes[5] say the variable was added back. Two people in that issue report still seeing it on 2.17.1.

I could not reproduce it with unmodified images. Version 2.17.0 defines $forward_host in /etc/nginx/nginx.conf, and 2.17.1 defines it in conf.d/include/proxy-variables.conf, which that nginx.conf includes. I did reproduce it by mounting the 2.16.0 nginx.conf over the 2.17.1 one, the way someone who customised that file through a volume would. The log repeated the error 30 times in 35 s and no port answered.

If that is your case, remove the mount or rebuild your file from the nginx.conf of the new image. The workaround from the issue, map $host $forward_host { default $host; } in http_top.conf, made nginx -t pass in my test, but it leaves an old nginx.conf on top of a new image.

Can I roll back to 2.16 to dodge the error?

I advise against it, for security reasons. On 18 November 2026 nginx released version 1.31.9, which fixes ten security bugs, and 1.30.7. One is CVE-2026-123007 (CVE stands for Common Vulnerabilities and Exposures), a memory corruption in HTTP/2 flow control. According to the nginx security advisories[6], it affects versions 1.9.5 to 1.31.8.

Inside the images, nginx -v answered openresty/1.31.1.1 on 2.16.0 and openresty/1.31.8.1 on 2.17.0 and 2.17.1. The first two sit inside the affected range. Version 2.17.1 prints the same number as 2.17.0 because it does not bump the version. Its notes say it uses an OpenResty base image with the fixes backported.

Pull request 44 of docker-nginx-full[7] lists which ones: CVE-2026-123633 and CVE-2026-123007, the two HTTP/2 bugs.

Rolling back to 2.16.0 leaves you with an nginx without those patches, and I did not test whether the database accepts the downgrade. Fixing the variable takes two minutes and keeps the patches. I did not verify on my own that the binary contains the fixes: I am relying on the release notes and the pull request.

FAQ

Am I affected if I never touched the custom configuration?

No. The 2.17 templates already use the new names in everything they generate, so a host with no custom configuration regenerates without an error. My a.test and c.test hosts, with HSTS enabled from the panel and nothing written by hand, went through every test without failing on their own.

Is there a version that fixes it by itself?

Not yet on 1 December 2026. The latest version is still 2.17.1, the template on the develop branch defines only the two new variables and issue 6059 is open. On 26 November pull request 6085[8] arrived, which defines $hsts_header again with each host's own HSTS value, but it is not merged yet. Before you apply this guide later on, check whether a 2.17.2 exists and whether its notes mention $hsts_header or that pull request.

Why did my nginx fail right after the upgrade when the lab one did not?

Issue 6059 describes the failure right after upgrading and restarting. In my lab the hosts had to be regenerated first. The difference depends on how many old files with the map remain in /data/nginx/: if none is left when the container restarts, nginx does not start. The fix is the same in both cases.

Conclusion

The unknown "hsts_header" variable error does not mean the upgrade to 2.17 went wrong: a variable disappeared and one of your hosts still uses it by hand. Run the script against the database, replace $hsts_header with $hsts_header_plain in the gear tab of each reported host and restart the container to confirm. If nginx is already down, the map in http_top.conf brings it up without a restart, and you can make the change calmly afterwards.

The Nginx Proxy Manager 2.16 upgrade guide explains the backup to take first. The Nginx Proxy Manager with Docker install guide covers a setup from scratch.

Sources: [1] Nginx Proxy Manager, issue 6059: unknown "hsts_header" variable[1], [2] Nginx Proxy Manager, pull request 5971: per-host HSTS sub-domains[2], [3] Nginx Proxy Manager, 2.17.1 release notes[5], [4] Nginx Proxy Manager, 2.17.0 release notes[9], [5] Nginx Proxy Manager, advanced configuration[3], [6] nginx, ngx_http_map_module[10], [7] nginx, security advisories[6], [8] Nginx Proxy Manager, issue 6043: unknown "forward_host" variable[4], [9] docker-nginx-full, pull request 44[7], [10] MDN, Strict-Transport-Security header[11].

Sources

  1. issue 6059
  2. pull request 5971
  3. advanced configuration documentation
  4. Issue 6043
  5. 2.17.1 release notes
  6. nginx security advisories
  7. Pull request 44 of docker-nginx-full
  8. pull request 6085
  9. Nginx Proxy Manager, 2.17.0 release notes
  10. nginx, ngx_http_map_module
  11. MDN, Strict-Transport-Security header