John Davidson

php - Nginx Config 2 Web Applications on one Server

0 comments
Message:


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?



My Answer:
server {
listen 80;
server_name 10.X.X.XX;

location /app/web {
alias /path/to/web/application;
try_files $uri $uri/ /app/web/index.php?$args;
}

location /app/api {
alias /path/to/api/application;
try_files $uri $uri/ /app/api/index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}

Rate this post

3 of 5 based on 6159 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us