<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Glad I helped ! :o)<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 Mon, Dec 29, 2014 at 3:52 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">
  
    
  
  <div 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><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>Le 29/12/2014 00:03, B.R. a écrit :<br>
    </div><div><div class="h5">
    <blockquote type="cite">
      <div dir="ltr">
        <div 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 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><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><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.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>
                <div><br>
                  <br>
                  _______________________________________________<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/mailman/listinfo/nginx</a><br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
nginx mailing list
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a></pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div><br></div></div>