I've tried already several ways that I've found over the internet but I still didn't manage to work.
What I want is, i have a server configuration for the url: www.domain.com where I have installed and configured a Drupal website.
I also have a subdomain, api.domain.com where I have installed and running a Laravel application.
IMPORTANT:
- And each of this projects, have it's own nginx configurations.
- Both projects are siblings projects at my Root directory.
What I need
That all requests for the URL www.domain.com/api are requested to the subdomain api.domain.com and if is a specific url like www.domain.com/api/option1/options2 request api.domain.com/option1/option2 without redirecting the user.
So I basically I need that the NGINX configuration for the Drupal ignore all the requests to the /api URL and request to the subdomain
Why I need
I need to have all subdomains and everything else under the same domain, because I only have the SSL to use on www.domain.com and not *.domain.com
I don't know if this is the best approach for my problem, but if you have any other suggestions I'm open.
Thanks in advance.
My own Answer
I couldn't reply my own question so here is the answer I manage to work.
location ^~ /api/ {
rewrite ^/api/?(.*)$ /$1 break;
proxy_pass http://api.domain.com;
}
And this will also force the final trailing slash.
If you don't want to force the trailing slash just remove the last one at the location