Nginx Config 2 Web Applications on one Server

Issue

This Content is from Stack Overflow. Question asked by TimoB2005

Good Morning guys,

i am trying to create an working Nginx Config.

I have two web applications:

  • /app/web
  • /app/api

My URL should look like this:

  • 10.X.X.XX => /app/web

  • 10.X.X.XX/api => /app/api

My current config:

server {
    listen 80 default_server;
 
    index index.php index.html index.htm;

    root /app/web;

    location /api {
      root /app/api;
    }

    location ~ [^/].php(/|$) {
        autoindex on;
        autoindex_exact_size on;
        try_files $uri =404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    error_log  stderr warn;
    access_log  /dev/stdout main;

    client_max_body_size 10M;
}

Any suggestions?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?