Multiple apps on the same Nginx domain

Asked

Viewed 918 times

4

Good morning guys, I’m cracking my head here.

I have a server with Nginx and in it I have two applications:

1 - Laravel App /usr/share/Nginx/html/Laravel/public

2 - Joomla app /usr/share/Nginx/html/joomla

The application in Laravel is the main one that must be accessed in 'http://domain.com.br/' and joomla must be accessed at 'http://domain.com.br/former'.

Below follows the default configuration code:

server {
listen 80;
listen [::]:80 ipv6only=on;

root /usr/share/nginx/html/laravel/public;
index index.php index.html index.htm default.html default.htm;

server_name 104.131.92.76;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ /antigo/ {
    root /usr/share/nginx/html/joomla;
    index index.php index.html index.htm default.html default.htm;

    try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
    try_files $uri /index.php =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}
}

What am I doing wrong?

  • Tries to change try_files $uri $uri/ /index.php?$args; for try_files $uri $uri/ /antigo/index.php?$args;.

  • Do a test on terminal runs nginx -t if you have error your conf. will show you which line is wrong.

1 answer

1

On the line try_files $uri $uri/ /index.php?$args; you are sending all the requisitions that give error in dominio.com.br/antigo/* for dominio.com.br/index.php from your other application. This is an easy-to-see error.

If you want to maintain optimal routing for both Joomla and Laravel (instead of keeping just one of them connected) on the same domain, it can be quite laborious to make it work.

Here is documentation on how to do this using Joomla at the root of the domain https://docs.joomla.org/Nginx

  • 1

    Friend and how would I do otherwise? Multiple domains and the same app?? The application would be in Vue.js and should receive a different parameter for each domain.

  • 1

    Probably easier than the above question. But in this case, better open a dedicated question for what you need (if you haven’t already done so).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.