Can someone share sample nginx Directive

Discussion in 'Installation/Configuration' started by mnzava, Nov 10, 2024.

  1. mnzava

    mnzava Member

    Hi,
    Can someone share nginx directives to be added to Nginx Directive Options Tab in ISPConfig?
    Things like:
    1. Change document root from web to public folder inside web
    2. Prevent directory listing for some directories
    3. Any other performance settings
    Regards
     
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    Code:
    ##subroot public ##
    directory listing should be off by default on nginx servers. so you shouldn't need to do anything to prevent it..

    you can enable it on a directory with:
    Code:
       location /somedir {
           autoindex on;
       }
    
    obviously, if it is on, you can disable it by changing it to 'autoindex off'


    Code:
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Xss-Protection "1; mode=block" always;
    add_header Referrer-Policy 'same-origin';
    add_header Content-Security-Policy "default-src 'self'; base-uri 'self'; frame-src 'self'; frame-ancestors 'self'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; form-action 'self';" always;
    
    using 'unsafe-inline' isn't recommended.. but unless you're specifying a hash, or random nonce (for every inline script/css on every page request) then wordpress sites will freak out if you provide any stricter CSP settings.
    and depending on the design/content of your site, you might need to change some of the other headers too.
     
    ahrasis likes this.

Share This Page