查看: 1653|回复: 0

[PHP学习] Laravel 5.5 官方推荐 Nginx 配置学习

发表于 2017-10-11 08:00:05
句号论坛

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

  1. server {
  2. listen 80;
  3. server_name example.com;
  4. root /example.com/public;
  5. add_header X-Frame-Options "SAMEORIGIN";
  6. add_header X-XSS-Protection "1; mode=block";
  7. add_header X-Content-Type-Options "nosniff";
  8. index index.html index.htm index.php;
  9. charset utf-8;
  10. location / {
  11. try_files $uri $uri/ /index.php?$query_string;
  12. }
  13. location = /favicon.ico { access_log off; log_not_found off; }
  14. location = /robots.txt { access_log off; log_not_found off; }
  15. error_page 404 /index.php;
  16. location ~ \.php$ {
  17. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  18. fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
  19. fastcgi_index index.php;
  20. include fastcgi_params;
  21. }
  22. location ~ /\.(?!well-known).* {
  23. deny all;
  24. }
  25. }
复制代码

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

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

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