Reverse proxy with nginx + app on Galaxy

What do the logs say? Any errors in consoles? What happens if you use the IP instead?

Logs::

nginx-proxy_1  | 172.19.0.1 - - [31/May/2022:10:24:10 +0000] "GET /524ea151167f0aa67862fb6b681b532466a7bc87.css?meteor_css_resource=true HTTP/1.1" 200 78 "http://localhost:3003/groups" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36"
nginx-proxy_1  | 172.19.0.1 - - [31/May/2022:10:24:10 +0000] "GET /9503405409bb540c2fde020180d23fadce7113ec.js?meteor_js_resource=true HTTP/1.1" 404 49 "http://localhost:3003/groups" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36"
nginx-proxy_1  | 172.19.0.1 - - [31/May/2022:10:24:10 +0000] "GET /9503405409bb540c2fde020180d23fadce7113ec.js?meteor_js_resource=true HTTP/1.1" 404 49 "http://localhost:3003/groups" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36"

Not working when used IP too i.e 127.0.0.1

Remove the rewrite from your nginx location block and just route /group and see what happens, looks like it has routed kind of but if you’re getting a blank page then the rewrite must be screwing with the meteor setup because the core needs to request it’s files and the rewrite is getting in the way so probably not compatible to do it this way.

Tried that as well. Backend also stopped working then

This is being returned if we try to call the homepage from the API.

The problem is with script tag I guess, its taking the src from as
localhost:3003/6cfc8da18cc913eeed05039f791171356d6650e0.js?meteor_js_resource=true

but NGINX detects this in the first block of location & thus it does not work


server{
        listen 3003;

        location / { #this gets executed
            proxy_pass http://main_web:3000; 
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'Upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }

        location ~ ^/group { #I need this to be executed
            rewrite ^/group/(.*) /$1 break;
            proxy_pass http://group:3001;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'Upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }

    }

Yes I think you have no choice but to setup another server block listening on another port and go at it that way so that meteor can load normally. Of course, just double checking - you have set your ROOT_URL correctly right? Because you must do that so that the assets can be loaded.

Yes ROOT_URL is correct.

This is what I think available options are

Please share your opinion if that could work

Honestly bro you just going for a complicated setup here imho. The moderator of this forum is very strict so I can’t say my honest opinion. You should just set one port for each and keep it simple. As a design methodology KISS is always best.

https://en.m.wikipedia.org/wiki/KISS_principle

I do agree with you but what im order to implement micro services architecture I am doing this, if there is any other alternative then pls let me know

Setup localhost same as before but instead of doing a rewrite, set the server name in the nginx config and do host based vhosts just the same as a server does and you won’t need to have a rewrite on a directory. You’ll need to make sure those hosts resolve to localhost in your hosts file that’s all.

Very easy and the standard way

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04