0
 root   /var/www/serve/il/gcc/public;
    etag off;
    add_header Pragma "public";
    add_header Cache-Control "public";

    brotli on;
    brotli_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/octet-stream;

    gzip on;
    gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/octet-stream;

    expires max;

 location ^~ /india {
        alias /var/www/serve/il/india/public;
        index index.php;
        try_files $uri $uri/ /index.php?$args;
    }
location  / {
        root /var/www/serve/il/gcc/public;
        index index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    include /etc/nginx/php.inc;
}

There are two projects with different roots. I am trying to get URL as

https://example.com/en-gc/site/index

and

https://example.com/en-in/site/index

I have tried various solutions but nothing seems to be working for this.

  • Possible duplicate: https://stackoverflow.com/questions/11570321/configure-nginx-with-multiple-locations-with-different-root-folders-on-subdomain – Alex Barker Aug 21 '19 at 20:10

1 Answers1

0

What do you mean by two PHP instances? You can simply have two different folders with a Yii2 project in each and serve them both from the same host, but I don't think that's what you meant. I think what you are asking is that you want a separate PHP instance for each site that is isolated from the other. If that is the case, you want to setup a separate vhost for each sub site, either by port or by domain + hosts file. Be sure you set the listen directive to 127.0.0.1 for each of these hosts so they are not accessible outside of the primary site. Then on the primary vhost, inside of your location blocks, use a reverse proxy to forward the requests to the correct 127.0.0.1 host you previously setup. There are a lot of examples out there for this kind of configuration.

See:

Alex Barker
  • 4,316
  • 4
  • 28
  • 47
  • I have given whole nginx configuration at the top with location directives below. I need solution for 2 folders with yii2 on same server block – user2453217 Jul 26 '19 at 04:59