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
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
I get
404 Not Found
And when I visit
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”?