I've configured before the following where I have 2 different apps under the same server but with different sub-domains. Something like:
domain.com
points toip1:3000
under root/var/www/html/site1
sub.domain.com
points toip1:3001
under/var/www/html/site2
What I'd like to do now, for SEO reasons, is to have all apps under the same domain. But in order to keep my resource usage low and to distribute a bit the load, I'd like for the apps to be on different machines/servers/ips. So what I imagine is the following:
domain.com
points toip1:3000
under root/var/www/html/site1
domain.com/site2
points toip2:3000
root/var/www/html/site2
How can I achieve this with NGINX? What do I need? Is it even possible?
I've looked a while for this and mostly what I find is the first case, but that's unrelated.
Any help would be appreciated. Thanks!
EDIT: To clarify, wouldn't this work?
server {
server_name domain.com;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:3000;
}
location /app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://some.other.external.ip:3000;
}
}