0

I have two applications. One is a Django app and the files for this is located at /home/founders/founders/back

The site is running and you can see it on founderslooking.com

I have another Vue site that forms part of the founderslooking.com site and the files are located at /home/founders/founders/dist

I want the Vue app to run at the location founderslooking.com/app

This is how I set it up. First here is the conf file for the Django site running at founderslooking.com

upstream founders_app_server {
        server unix:/home/founders/founders/run/gunicorn.sock fail_timeout=0;
}

server {
        listen 80;
        server_name founderslooking.com default_server;

        client_max_body_size 4G;

        location / {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_set_header Host $http_host;

                proxy_redirect off;

                if (!-f $request_filename) {
                        proxy_pass http://founders_app_server;
                }

                # auth_basic "Testing";
                # auth_basic_user_file /home/founders/founders/.htpasswd;
        }
        location /static/ {
                autoindex on;
                root /home/founders/founders/back;
        }
}

and here is my set up for the Vue site I need to make run on founderslooking.com/app:

server {
        listen 80;

location  /app/ {
        alias /home/founders/founders/dist/;
        try_files $uri $uri/ /index.html;
        }
}

the conf files are located in sites-available and are called founders.conf and app.conf and I have sim links to those files in sites-enabled.

If I go to founderslooking.com/app/user/1 which is the currently logged in user then I get a Not Found page.

How am I then supposed to host a second site (static) on the same domain? Why is Nginx not getting the index.html file in /home/founders/founders/dist if I go to founderslooking.com/app? Isn't that what the alias /home/founders/founders/dist do?

5
  • 1
    If it's the same domain, it needs to be the same server block. See How nginx processes a request. Commented May 29 at 7:15
  • I had it on the same server block and that didn't work either. This is really confusing Commented May 29 at 7:23
  • Looking at your location /app/ block, the correct URL for your index file is /app/index.html, which should be at the end of the try_files statement instead of /index.html Commented May 29 at 7:28
  • I did what you said and I put it all on the same server block again and made the change to the try_files directive it still doesn't work. There is no app directory so why try_files $uri $uri/ /app/index.html? Now if I go to founderslooking.com/app I get a forbidden yet the folder belongs to the user founder who owns all the folders and files in /home/founders/founders. If I go founderslooking.com/app/user/1 I get an internal server error. In the error log I see this: 2024/05/29 07:33:44 *1 directory index of "/home/founders/founders/dist" is forbidden. How can it be forbidden? Commented May 29 at 7:47
  • I also see this in the error log: 2024/05/29 07:48:20 [error] 29026#29026: *9 rewrite or internal redirection cycle while internally redirecting to "/app/index.html", client: 102.32.83.118, server: founderslooking.com, request: "GET /app/user/1 HTTP/1.1", host: "founderslooking.com" Commented May 29 at 7:49

0

You must log in to answer this question.

Browse other questions tagged .