<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Thanks you for your answer, you helped me to make it working. ;)<br>
    This is my final configuration :<br>
    <br>
    <pre wrap=""><cite>server {</cite><cite>
</cite><cite>       listen   80;
        server_name mydomain;
        root /server/www; </cite><cite>
</cite><cite>
</cite><cite>       location @rewriteMainApp {</cite><cite>
</cite><cite>               rewrite ^(.*)$ /app.php/$1 last;</cite><cite>
</cite><cite>       }</cite><cite>
</cite><cite> </cite><cite>
</cite><cite>       location @rewriteOtherApp1 {</cite><cite>
</cite><cite>               rewrite ^(.*)$ /subdir1/app.php/$1 last;</cite><cite>
</cite><cite>       }</cite><cite>
</cite><cite>
</cite><cite>       location /subdir1 {</cite><cite>
</cite><cite>               alias /server/www/other-app1/web;</cite><cite>
</cite><cite>               index app.php;</cite><cite>
</cite><cite>               set $subfolder "other-app1/web";</cite><cite>
</cite><cite>               try_files $uri @rewriteOtherApp1;</cite><cite>
</cite><cite>       }</cite><cite>
</cite><cite>
</cite><cite>       location / {</cite><cite>
</cite><cite>               root /server/www/main-app/web;</cite><cite>
</cite><cite>               index app.php;</cite><cite>
</cite><cite>               set $subfolder "main-app/web";</cite><cite>
</cite><cite>               try_files $uri @rewriteMainApp;</cite><cite>
</cite><cite>       }</cite><cite>
</cite><cite>
</cite><cite>       # PROD</cite><cite>
</cite><cite>       location ~ /app\.php(/|$) {</cite><cite>
</cite><cite>               fastcgi_pass unix:/var/run/php5-fpm.sock;</cite><cite>
</cite><cite>
</cite><cite>               include fastcgi_params;</cite><cite>
</cite><cite>               fastcgi_param SCRIPT_FILENAME $document_root/$subfolder/app.php;</cite><cite>
</cite><cite>       }</cite><cite>
</cite><cite>}</cite></pre>
    <br>
    <br>
    <div class="moz-cite-prefix">Le 29/12/2014 00:03, B.R. a écrit :<br>
    </div>
    <blockquote
cite="mid:CALqce=13G-mqNu2i2XfEV=QooW2sB5LeZit5MtHz0iLs-pFj7Q@mail.gmail.com"
      type="cite">
      <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 moz-do-not-send="true"
                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 moz-do-not-send="true" href="http://mydomain/"
                        target="_blank">http://mydomain/</a>           
                         -> main app<br>
                      <a moz-do-not-send="true"
                        href="http://mydomain/subdir1" target="_blank">http://mydomain/subdir1</a> 
                       -> another app<br>
                      <a moz-do-not-send="true"
                        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 moz-do-not-send="true"
                        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 moz-do-not-send="true"
href="http://forum.nginx.org/read.php?2,255806,255806#msg-255806"
                        target="_blank">http://forum.nginx.org/read.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>
                  _______________________________________________<br>
                  nginx mailing list<br>
                  <a moz-do-not-send="true"
                    href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
                  <a moz-do-not-send="true"
                    href="http://mailman.nginx.org/mailman/listinfo/nginx"
                    target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
nginx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:nginx@nginx.org">nginx@nginx.org</a>
<a class="moz-txt-link-freetext" href="http://mailman.nginx.org/mailman/listinfo/nginx">http://mailman.nginx.org/mailman/listinfo/nginx</a></pre>
    </blockquote>
    <br>
  </body>
</html>