<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">You are using the same named location as the fallback of the try_files directive, although you are dealing with three different paths.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Why do not you use one fallback named location per app location, each rewriting to the correct path?<br></div><div class="gmail_extra"><div><div class="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
<br><div class="gmail_quote">On Sun, Dec 28, 2014 at 10:16 PM, Naji Astier <span dir="ltr"><<a href="mailto:naji.demolitionman@gmail.com" target="_blank">naji.demolitionman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Le 28/12/2014 20:30, Steve Holdoway a écrit :<div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sat, 2014-12-27 at 05:52 -0500, Claros wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello everybody !<br>
<br>
I just switched from Apache2 to Nginx and I met some issues having the same<br>
configuration. What I want to do is having multiple Symfony2 apps on the<br>
same domain name. Each app will have a subdirectory and a main app will be<br>
on the domain name itself. For instance :<br>
<a href="http://mydomain/" target="_blank">http://mydomain/</a> -> main app<br>
<a href="http://mydomain/subdir1" target="_blank">http://mydomain/subdir1</a> -> another app<br>
<a href="http://mydomain/subdir2" target="_blank">http://mydomain/subdir2</a> -> yet another app<br>
One of Symfony2 feature is to have only three php files to be executed, and<br>
all the URL are rewritten to those files. You can found basic configuration<br>
for Symfony2 at this address if you need more information :<br>
<a href="http://wiki.nginx.org/Symfony" target="_blank">http://wiki.nginx.org/Symfony</a><br>
Now after many hours of configuration, with the help of debug logs, I almost<br>
did it. This is my current configuration :<br>
<br>
server {<br>
listen 80;<br>
server_name mydomain;<br>
root /server/www/main-app/web;<br>
<br>
location @rewriteapp {<br>
rewrite ^(.*)$ /app.php/$1 last;<br>
}<br>
<br>
location /subdir1/ {<br>
# alias /server/www/other-app1/web;<br>
set $root "/server/www/other-app1/web";<br>
# try to serve file directly, fallback to app.php<br>
try_files $uri @rewriteapp;<br>
}<br>
<br>
location / {<br>
index app.php;<br>
set $root "/server/www/main-app/web";<br>
# try to serve file directly, fallback to app.php<br>
try_files $uri @rewriteapp;<br>
}<br>
<br>
# PROD<br>
location ~ ^/app\.php(/|$) {<br>
fastcgi_pass unix:/var/run/php5-fpm.sock;<br>
fastcgi_split_path_info ^(.+\.php)(/.*)$;<br>
<br>
include fastcgi_params;<br>
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;<br>
fastcgi_param SCRIPT_NAME $fastcgi_script_name;<br>
fastcgi_param PATH_INFO $fastcgi_path_info;<br>
}<br>
}<br>
<br>
Why did I create a variable "$root" ? Because when I was using the root (or<br>
alias) directive in a location block and the variable $document_root, I<br>
found out that this variable has as final value (in the location app.php)<br>
the first root directive in the server or the default root location.<br>
With this configuration, it almost work. The main app works and the<br>
subdirectories are correctly sent to their directory. The last problem is<br>
that the URI processed by the file app.php also contains the subdirectory in<br>
it, so the others apps send 404 for all the URL. I tried to fix that by<br>
changing "REQUEST_URI" parameter, but with that the app.php generate wrong<br>
URL without the subdirectory.<br>
<br>
So is their a way to achieve this configuration ? Thanks you !<br>
<br>
Posted at Nginx Forum: <a href="http://forum.nginx.org/read.php?2,255806,255806#msg-255806" target="_blank">http://forum.nginx.org/read.<u></u>php?2,255806,255806#msg-255806</a><br>
</blockquote>
Try using a map to set the $root...<br>
<br>
Steve<br>
<br>
</blockquote></div></div>
Ok I did not know the map system, it is interesting. But it is only simplifying my configuration, not solving the problem.<div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<u></u>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/<u></u>mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br></div></div>