NGINX + Symfony – 内部指令是什么redirect?

在官方的NGINX文档中,他们具有以下用于生产级Symfony的configuration

# PROD location ~ ^/app\.php(/|$) { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; # When you are using symlinks to link the document root to the # current version of your application, you should pass the real # application path instead of the path to the symlink to PHP # FPM. # Otherwise, PHP's OPcache may not properly detect changes to # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 # for more information). fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; # Prevents URIs that include the front controller. This will 404: # http://domain.tld/app.php/some-path # Remove the internal directive to allow URIs like this internal; } 

完整的configuration文件可以在这里find

什么是internal实际redirect? 评论说,它从URI中删除了前端控制器,但我不完全知道如何。

它不会redirect任何东西。 它指定了如何处理外部redirect ,即像http://example.com/app.php/some-path这样的位置; 虽然设置,他们应该返回404 ,只允许内部redirect 。 作为内部redirect处理的条件列在internal指令的文档中:

指定给定位置只能用于内部请求。 对于外部请求,将返回客户端错误404(Not Found)。 内部要求如下:

  • error_pageindexrandom_indextry_files指令redirect的请求;
  • 来自上游服务器的X-Accel-Redirect响应头字段X-Accel-Redirect的请求;
  • 由ngx_http_ssi_module模块的include virtual命令和ngx_http_addition_module模块指令形成的子请求;
  • 请求由rewrite指令改变。