# Nginx configuration problem when splitting across front & backends, when using php?

**URL:** <https://www.ruby-forum.com/t/nginx-configuration-problem-when-splitting-across-front-backends-when-using-php/243772>\
**Category:** NGINX\
**Created:** [January 4, 2016, 1:18am UTC](https://www.ruby-forum.com/t/nginx-configuration-problem-when-splitting-across-front-backends-when-using-php/243772 "2016-01-04T01:18:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [January 4, 2016, 1:18am UTC](https://www.ruby-forum.com/t/nginx-configuration-problem-when-splitting-across-front-backends-when-using-php/243772/1 "2016-01-04T01:18:28Z")

</div>

I installed an Nginx server this weekend.

I got the Symfony PHP framework, and a test app, running on it, using  
php-fpm, and a simple all-in-one Nginx config.

I’m trying to figure out splitting front- and back-ends using Nginx  
proxy.

I set up a FrontEnd Nginx config

server {  
server\_name test.lan;  
listen 10.0.0.1:443 ssl http2;

```
root /dev/null;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log info;
autoindex off;
rewrite_log off;
ssl on;
ssl_verify_client off;
ssl_certificate "ssl/test.crt";
ssl_trusted_certificate "ssl/test.crt";
ssl_certificate_key "ssl/test.key";
include includes/ssl.conf;

location / {
  proxy_pass http://127.0.0.1:10000;
}

```

}

and the Backend proxy listener for it,

server {  
server\_name test.lan;  
listen 127.0.0.1:10000 default;  
root /srv/www/test/symfony/web/;  
access\_log /var/log/nginx/access.log main;  
error\_log /var/log/nginx/error.log info;  
ssl off;  
gzip off;  
rewrite\_log on;

```
location / {
  try_files $uri /app.php$is_args$args;
  fastcgi_intercept_errors on;
}

location ~ ^/(app_dev|config)\.php(/|$) {
  fastcgi_pass http://127.0.0.1:9000;
  fastcgi_split_path_info ^(.+\.php)(/.*)$;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME 

```

$realpath\_root$fastcgi\_script\_name;  
fastcgi\_param DOCUMENT\_ROOT $realpath\_root;  
}

```
location ~ ^/app\.php(/|$) {
  fastcgi_pass http://127.0.0.1:9000;
  fastcgi_split_path_info ^(.+\.php)(/.*)$;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME 

```

$realpath\_root$fastcgi\_script\_name;  
fastcgi\_param DOCUMENT\_ROOT $realpath\_root;  
internal;  
}  
}

When I start Nginx I get no errors.

When I visit

[https://test.lan/](https://test.lan/)

I see

Welcome to Symfony 3.0.1

Your application is ready to start working on it at:  
/srv/www/test/symfony/

So that’s the same as with the all-in-one Nginx config.

But, with this split config I’m trying out, when I visit

[https://test.lan/app.php](https://test.lan/app.php)

I get

404 Not Found

And when I visit

[https://test.lan/app\_dev.php](https://test.lan/app_dev.php)

I get

File access denied. cref: app\_dev.php for more info.

Since I got this working right in my all-in-one config, but not in my  
split-config, I guess the problem’s in my config and not with Symfony or  
php-fpm.

How come I can get “/” working but not either “/app.php” or  
“/app\_dev.php”?
