Hosting multiple websites on same server with mup and nginx

Hey All,

I followed the following guide:
http://julian.io/how-do-i-host-multiple-meteor-apps-on-one-digitalocean-droplet/

But I when I did it, I setup two www.domain.com type websites, lets call them:

For some reason, every time I try to navigate to www.domain2.com, it takes it redirects to www.domain1.com

I don’t know what I’d done wrong…

Here’s the conf files for both sites:

www.domain1.com

server {
  listen *:80;
  server_name  domain1.com;
  return 301 $scheme://www.domain1.com$request_uri;
}

server {
  listen                *:80;
  server_name           www.domain1.com;
  access_log            /var/log/nginx/app.dev.access.log;
  error_log             /var/log/nginx/app.dev.error.log;

  location / {
    proxy_pass http://localhost:3010;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header X-Forwarded-For $remote_addr;
  }
}

www.domain2.com

server {
  listen                *:80;
  server_name           www.domain2.com;
  access_log            /var/log/nginx/app.dev.access.log;
  error_log             /var/log/nginx/app.dev.error.log;

  location / {
    proxy_pass http://localhost:4120;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header X-Forwarded-For $remote_addr;
  }
}

have you got a default declaration hiding in conf.d/?

Nope, it’s entirely empty.

Options:

  1. Check all the enabled configs. Somewhere you may have a redirect. The provided configs look ok.
  2. If you are using cloudflare, your redirect might have been cached, you will need to purge it.
  3. If you are checking on chrome, again redirect cached, needs a hard refresh, or would have been fixed by now (it takes a few minutes to a few hours).
2 Likes