标头未添加到特定路径NGINX,Laravel

时间:2019-10-29 02:02:19

标签: php laravel nginx

尝试将no索引标头添加到特定路径(/ path),但未显示。当我将其与其他add_header行添加到一起时,它显示得很好,但放在位置/ path {}甚至位置/ {}中时却显示不了。我已经在论坛上阅读了很多答案,但无法弄清楚问题所在。有人知道或看到我在做什么错吗? Nginx版本是1.13.3

这是我的nginx文件:

server {
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;

    server_name mydomain.com;
    root /home/forge/mydomain.com/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";
    add_header Referrer-Policy "origin";
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /path {
        add_header X-Robots-Tag "noindex" always;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {

        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

0 个答案:

没有答案