Nginx config to serve react using subpath

Viewed 159

I need to serve a react app on a subpath domain http://domain.dev/myreactapp

And I can't find a configuration to serve the app using nginx.

I'm using the nginx docker container.

I already tried a lot of stuff but this is my conf right now.

server {
    listen 80;

    root /usr/share/nginx/html;
    index index.html;

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

The the big nginx instance points http://mydomain.dev/myreactapp to another server that will serve static files with nginx on a docker container (the nginx:1.16.0-alpine container)

My react app will only be served by that url, the top domain is pointing to another server.

But I can't make the app respond to the subpath.

If I ran the second docker image on my machine, it only respond to the top level.

I don't know what I need to set it up on the second nginx to serve the app on the http://mydomain.dev/myreactapp subpath.

0 Answers
Related