Warning: Unnecessary HSTS header over HTTP

Discussion in 'ISPConfig 3 Priority Support' started by ktownmods, Apr 10, 2022.

  1. ktownmods

    ktownmods Member HowtoForge Supporter

    How can i fix that?
    Code:
    Warning: Unnecessary HSTS header over HTTP
    in my website Nginx Directives i have
    Code:
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    You could warp the line e.g. in an if clause to set it only for https.
     
  3. ktownmods

    ktownmods Member HowtoForge Supporter

    Can you give me an example?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    You can e.g try this:

    Code:
    if ($scheme == "https") {
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
    }
     
  5. ktownmods

    ktownmods Member HowtoForge Supporter

    Code:
    WARNING - Reason for nginx restart failure: nginx: [emerg] unexpected "==" in condition in /etc/nginx/sites-enabled/100-example.com.vhost:147
    nginx: configuration file /etc/nginx/nginx.conf test failed
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Try with one = instead of ==
     
  7. ktownmods

    ktownmods Member HowtoForge Supporter

    Code:
    WARNING - Reason for nginx restart failure: nginx: [emerg] "add_header" directive is not allowed here in /etc/nginx/sites-enabled/100-example.com.vhost:148
    nginx: configuration file /etc/nginx/nginx.conf test failed
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, then it might be that you can't use an if statement indeed. So the best option is probably to ignore the warning at all then.
     
    ktownmods likes this.

Share This Page