Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've opened a similar thread some days ago and I know there are also some similar threads out there with the multiple location issue regarding Nginx.

But I can't find a solution for the problem. In addition in the old thread a part of the main problem was solved, so i didn't want to add additional questions too. Let me explain the current situation.

I've developed a single page application (in the top of backbone) and have already merged it to a hybrid application with Wordpress. Now the last task is to include also a PHP-Application (based on ZF) which is responsible to render some specific pages (like user-profiles, so that the profiles can be fetched from search bots).

Here is the current configuration:

server {

  server_name www.domain.at domain.at;
  index index.php;

  error_log /var/www/log/error.log debug;

  root /var/www/api/public;

  location = / {
    proxy_pass https://app.domain.at/;
    #alias /var/www/app/public;
    #try_files $uri $uri/ /index.html;
  }

  # rewrite for all routes matching activites (also other routes need to be added)
  location ^~ /activities 
  {
      rewrite ^ / last;
  }

  location ^~ /dashboard 
  {
      rewrite ^ / last;
  }

  location /shared 
  {
      root /var/www/app/src;
  }

  location ^~ /trainers
  {
    # let's process Zend-Framework here
    # if ZF is installed in another location, then
    #alias /var/www/api/public;

    #try_files $uri $uri/ /index.php$is_args$args;

    proxy_pass https://api.domain.at/;
    proxy_set_header Host $host;

    # process PHP here
    #location ~* ^/(.*\.php)$ {
      # directives to process PHP
      #fastcgi_split_path_info ^(.+\.php)(/.+)$;
      #fastcgi_pass unix:/var/run/php5-fpm.sock;
      #fastcgi_index index.php;
      #include fastcgi_params;
    #}
  }

  location / {
    # let's process WordPress here

    # if WordPress is installed in another location, then
    alias /var/www/web/;

    try_files $uri $uri/ /index.php;

    # process PHP here
    location ~* ^/(.*\.php)$ {
      #directives to process PHP
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
    }
  }
}

I've defined different locations. Some redirect to the index.html of the single page app. In addition also Wordpress is defined as fallback, if none of the routes match.

The remaing problem are the routes matching ^~ /trainers/ ... So if that url like http://www.domain.at/trainers/tennis/cityname/trainername is openend, the page should be served by the Zend Framework. With the server-side rendered page I'm able to setup all relevant meta tags.

In addition I uploaded a short extract of the nginx-log to pastebin

debug log

If you take a look at the debug-log everything seems to work fine until line 42. There nginx tries to use file "/var/www/api/public/index.php" ... which is the index.php file of ZF. But then on 43 there is an internal redirect, and it seems that the process starts again. And on line 74 you see that then the index.php of wordpress (/var/www/web) is used, to render the requested url.

Does anybody has an idea or maybe another approach?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.