1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Is there a way to have a Angular application in the root folder and another in a subdirectory...

Discussão em 'Angular' iniciado por fieldhof, Outubro 1, 2024 às 10:22.

  1. fieldhof

    fieldhof Guest

    I have 2 seperate Angular applications, one on dashboard.example.com which points to /var/www/dashboard.example.com and one on data.example.com. I want the second application to be accessible through dashboard.example.com/data. I don't want to redirect people.

    First thing I tried was creating a subdirectory /var/www/dashboard.example.com/data and putting all the files from data.example.com in it. I've changed the base_href of the index.html file in this subdirectory to /data.

    This works fine while loading the page from dashboard.example.com/data. When I click through the pages and reload it (ie dashboard.example.com/data/locations), then it will show the 404 page from the dashboard application, while I'm trying to access a page from /data. It seems that nginx is defaulting to /var/www/dashboard.example.com/index.html instead of /var/www/dashboard.example.com/data/index.html. As I read the nginx.conf, this is exactly what it's meant to do. I then tried to add a location directive to nginx.conf, but that wouldn't do the trick.

    location /data/ {
    alias /var/www/dashboard.example.com/public_html/data/;
    try_files $uri $uri/ /index.html$is_args$args;
    }

    location / {
    try_files $uri $uri/ /index.html$is_args$args;
    }


    I also tried the following, but that wouldn't do the trick either

    location /data/ {
    index data/index.html
    try_files $uri $uri/ data/index.html$is_args$args;
    }

    location / {
    try_files $uri $uri/ /index.html$is_args$args;
    }


    It's all a bit confusing and hard to understand, but hopefully somebody can help me understand why the changes to nginx.conf won't work.

    Continue reading...

Compartilhe esta Página