Laravel 5.5 官方推荐 Nginx 配置学习

Laravel 5.5 版本官方放出了 Nginx 服务器的配置,中文文档:服务器配置 Nginx

server {
    listen 80;
    server_name example.com;
    root /example.com/public;

    add_header X-Frame-Options "SAMEORIGIN";   
    add_header X-XSS-Protection "1; mode=block"; 
    add_header X-Content-Type-Options "nosniff"; 

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        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$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

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

自己并不擅长 Nginx,相信很多朋友跟我一样,让我们一起学习下 Nginx 的相关知识 : )

1. add_header X-Frame-Options "SAMEORIGIN";

X-Frame-Options 响应头是用来给浏览器指示允许一个页面可否在 ,