Score:1

Nginx: Serve URL path by different config file

um flag

I have 2 different application running on the server and both should be served by the same domain, let's say CMS1 will be served by domain.com while CMS2 served by domain.com/path

I have each CMS working properly by separated domains. But, I need in some way, when someone go to domain.com/path, nginx serve the site from CMS2.conf configuration file. while the main domain is served from the cms1.conf

I tried to have some configs in one file, but can't have location block inside another location block

Any advise?

ws flag
"but can't have location block inside another location block" - yes you can, but there are some limitations. If you had posted the config you tried and the corresponing error messages you might have a more explicit answer sooner.
Score:0
gg flag

For using different config files, you could use nginx's include directive.

Addressing the question, using the same server block with multiple location blocks (https://nginx.org/en/docs/http/ngx_http_core_module.html#location) could achieve this by serving based on path.

(Note: Would've asked for clarification or an example of what you've tried in a comment but don't have enough reputation yet.)

in flag
Welcome to SF. You could improve your answer and thus increasing the chance of getting upvotes by adding an example instead of just linking to the documentation.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.