Multiple meteor applications using the same domain in digitalocean using nginx?


#1

I’m trying to host 2 applications in the same droplet in digitalocean by using nginx

But so far I’ve only been able to get the root application running (the one without example.com/secondapp)

I want to be able to not use a subdomain and just use example.com/secondmeteorapp to be able to access it.

My sites-enabled/default looks like this:

server {
        listen 80;
        #listen 443 ssl;
    server_name example.com/;
    #ssl_certificate /etc/nginx/ssl/ssl-bundle-myApp-domain-com.crt;
    #ssl_certificate_key /etc/nginx/ssl/myApp_domain_com.key;

    location /dragonfire {
        proxy_pass http://localhost:4000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forward-Proto http;
        proxy_set_header X-Nginx-Proxy true;

        proxy_redirect off;

    }
    location /images {
            alias /home/dragonfire-build/bundle/programs/web.browser/assets/images;
            access_log off;
            expires max;
    }

    location /fonts {
        alias /home/dragonfire-build/bundle/programs/web.browser/assets/images;
        access_log off;
        expires max;
    }

    location "^/[a-z0-9]{40}\.(css|js)$" {
        root /home/dragonfire-build/bundle/programs/web.browser;
        access_log off;
        expires max;
    }

}

however, when I access http://serverIpAddress/dragonfire it can’t find the css or javascript giving me this error:
GET http://myipaddress/1f3848edee9e199050b9b1965b9e697aa714b9f3.css?meteor_css_resource=true

GET http://myipaddress/6e48198c6b584ff79c86e0c624a65b4853faaf50.js?meteor_js_resource=true 404 (Not Found)

I can access the app if I go directly through the IP address and port but not via the nginx way

QUESTION

How can I access a second app using the same domain but with a /mysecondapp (in this case /dragonfire at the end?


#2

Hi @jsantana

Did you end-up solving this issue? I am facing the same. Any clues?

Many thanks :slight_smile:


#3

Guys, this is more complicated than it needs to be, just use subdomains. Meteor apps are full fledged web apps that control URL paths (if you use routers of course)


#4

Yeah, it’s clear why the css and js isn’t being located, because nginx is configured to look into your dragonfire-build directory. You could have something that resembles an if else in that command, but it seems like having a subdomain is the easiest and most followed path.