[SOLVED] Nginx Config 2 Web Applications on one Server


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?


  1. Just copy and paste the same config into a new file
  2. Name it the same as the subdomain you want it to run on
  3. Give the path to the folder
  4. Add the new subdomain to the hosts file
  5. Restart nginx

This Question was asked in StackOverflow by TimoB2005 and Answered by Usama Arslan It 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?