Secure your SWAG / NGINX server/ docker - get rid of the default page

  • I don't know if this has been issued already before. At least i did not see this anywhere. So if redundant, please ignore/remove/correct.


    The available guides i read giving instructions how to set up SWAG, Nextcloud and other dockers in subfolders do not cover how to obfuscate the default page of the / root of the site.

    I think it is a good idea to do that in order to prevent potential attacks.

    It is quite easy to achieve.


    I did this by altering my default.conf in my SWAG docker (swag/nginx/site-confs/default.conf).

    Just edit the section location and "return 444" to present an error to anyone visiting the root of the site.


    Code
    location / {
    
    return 444;


    All subfolder sites will continue to work.



    Furthermore I think it makes sense for many to exclude their sites from Google and other crawling. It is quite easy to search google for sites that give default answers like the above described, making them an easy target for hackers that specialize on a specific webservers/ attacks.


    Also this can be achieved quite easily by adding the following line to the very beginning of the server block in the default.conf file:


    Code
    add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";


    I hope this helps. There are probably quite a number of people setting up webservers and exposing them unintentionally.

    - OMV7 on Asus Prime N100 -

    Snapraid on 2 Data drives & 1 Parity

    latest proxmox kernel

  • crashtest

    Approved the thread.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!