Set X-Robots-Tag in ispconfig custom nginx settings

Discussion in 'Installation/Configuration' started by sjak_congnac, Jan 1, 2026.

  1. sjak_congnac

    sjak_congnac New Member

    Hello

    My goals is to be able to set X-robot-Tags based on the content of the url. My current setup is like this
    Internet <--> Nginx Proxy Manager(docker) <--> ISPconfig (based on Nginx)

    One of my sites is a (troubled) woocommerce site.

    Whenever an url is accessed wich has add-to-cart in it i want it to add the X-Robots-Tag "noindex"(perhaps others in the future)

    What i have tried:
    In Nginx Proxy Manager:
    Code:
    location ~*^(/.*)/add-to-cart(/.*)?$ {
        add_header X-Robots-Tag  "noindex";
        try_files $uri $uri/ /index.php?$args;
    }
    
    I also tried variations of
    
    location ~* add-to-cart {
        add_header X-Robots-Tag  "noindex";
        try_files $uri $uri/ /index.php?$args;
    }
    
    Furthermore i tried using a map like this
    Code:
    map $uri $robots_tag {
        ~*^/add-to-cart(/.*)?$  "noindex";
         default "";
    }
    
    and then add to the / location
    
    add_header X-Robots-Tag $robots_tag always;
    Did not work, i tried the same on ISPconfig level with similair results

    As far as i know none of the NGINX instances activly removes X-Robot-Tags, so once set correctly they are bound to stay visible

    Is there a way i can reach my goals using custom nginx settings in ISPconfig?

    Thank you in advance for your insights
     

Share This Page