1

I am trying to configure Nginx (over debian 10) to serve two fronts (npm run build) of react.

All works fine on the first app "/", but not on "/administracion/" This is the configuration that I am using, and when I access I receive a 403. It does not seem like a permission problem, because it does not matter what I load, I always receive 403.

  server {
        listen 80;
        server_name x.net;
        root /var/www/html/front_web/build;

        index index.html;

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

        location /administracion/ {
                alias /var/www/html/front_admin/build;
                try_files $uri $uri/ /index.html;
        }
  }

The App is created with react-router (I think this does not affect anything).

1 Answer 1

3

Are you using any routing libraries? If this is a CRA app, try setting the homepage property. Otherwise all your JS and assets will try to be served from root.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes! I had configured the package.json but not the BrowseRouter. Now it works, but only in the baseurl of the second app, when it tries to load a path beyond (/ base / x) it returns to the main App with no content. Should I configure some routes in the routing of the main App?
@AlfredoHinarejos I had the very same problem yesterday where /some/path was not working while /some/path/ with the trailing slash did work when accessed in the browser. Haven't figured it out completely yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.