Hi, I am using HestiaCP default setup with Nginx proxy+Apache web server. For header security settings. should I add on both NGINX and Apache? will it make any benefit or will be excessively double loaded?
Thanks
NGINX
add_header Content-Security-Policy upgrade-insecure-requests;
add_header X-XSS-Protection “1; mode=block”;
add_header X-Content-Type-Options “nosniff”;
add_header Expect-CT ‘enforce; max-age=7776000’;
add_header X-Frame-Options “SAMEORIGIN”;
APACHE
Header always set Strict-Transport-Security: “max-age=31536000” env=HTTPS
Header always set X-Content-Type-Options “nosniff”
Header always set X-XSS-Protection “1; mode=block”
Header always set Expect-CT “max-age=7776000, enforce”
Header always set Referrer-Policy: “no-referrer-when-downgrade”
Header always set Content-Security-Policy “upgrade-insecure-requests”
You can create specific web templates for your sites or you can also add conf files nginx.conf_whatever and nginx.ssl.conf_whatever and add there your directives to add the needed headers.
Those files must be created in /home/YourUser/conf/web/YourDomain/. Hestia web templates include these directives that will load those files.
In nginx.conf:
[...]
include /home/YourUser/conf/web/YourDomain/nginx.conf_*;
[...]
In nginx.ssl.conf:
[...]
include /home/YourUser/conf/web/YourDomain/nginx.ssl.conf_*;
[...]
Those files won’t be modified in upgrades or rebuilding your site. The same if you prefer to create your own web template.
Those directives are global, so you can’t add them inside a VirtualHost. Also, there’s no need to include them, nobody will connect directly to Apache. Clients will only see Nginx, and Nginx already provides this “protection”.
Coz when I am doing phpinfo, I can still see the Apache version. (not sure if this is related to I’ve removed all proxy extension because my web app have issue with thus)
I will focus on adjusting other things primarily on Nginx now. Thanns
And then I’ve tried to run security scan from several website. Most are fine, but cyberchief.ai gives me some other security advise on Cross-Origin-XXXX
Then I try to search through google, but I think I am too limited in my knowledge to understand. May I seek for you advise whether needed to apply those Cross-Origin-XXXX header as well?
Yes, but if you want to increase the default value of HSTS set by Hestia, you’ll have to either set hsts with v-add-web-domain-ssl-hsts than edit $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.hsts.conf
Or put it directly in a template as Jason did
Depending on what you’re doing one can be easier than the other