I don't want HSTS on port 8001 but on other ports
I have hsts set for my domain in Nginx.conf . It will redirect my website to https for main port 80. But I don't want the redirect to happen for my other port. How do I do this?
Solution 1:
Simplified: HSTS is a domain wide policy to that forbids the use of plain http on your domain. That policy is regardless of which port you want to access over plain http, be it the default port 80 or another like 8001.
If you request your domain onhttp://www.example.com
that is effected by rewriting the uri tohttps://www.example.com
On other ports than port 80 that happens by rewriting plain http requests to https but maintaining the non-standard port,http://www.example.com:8001/page.html
should be rewritten intohttps://www.example.com:8001/page.html
So as long as you configured port 8001 to support TLS you’re good.
https://www.rfc-editor.org/rfc/rfc6797
The UA MUST replace the URI scheme with "https" [RFC2818], and
if the URI contains an explicit port component of "80", then
the UA MUST convert the port component to be "443", or
if the URI contains an explicit port component that is not
equal to "80", the port component value MUST be preserved;
otherwise,
if the URI does not contain an explicit port component, the UA
MUST NOT add one.
NOTE: These steps ensure that the HSTS Policy applies to HTTP
over any TCP port of an HSTS Host.