Meteor/Nginx on Ubuntu 16.04 forcing non-www to https

May 22, 2016 594 views
Nginx DNS Ubuntu 16.04

Hiyas, I'm following this tutorial - https://gist.github.com/jamiewilson/4e1d28f9a200cb34ad59 - to point my godaddy domain - gamengineers.co to a meteor app deployed to a DO droplet. I'm also using mupx to deploy the meteor app - https://github.com/arunoda/meteor-up/tree/mupx.

Whatever I do, whenever I type in gamengineers.co, it takes me to https://www.gamengineers.co. Now I did add 2 A records to my DO domain, @ to ip, and www to ip.

Here's my nginx vhost -

server {
  listen        80;
  server_name   gamengineers.co;
  access_log    /var/log/nginx/app.dev.access.log;
  error_log     /var/log/nginx/app.dev.error.log;

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

And I added to this nginx default -

# redirect www to non-www
server {
    listen 80;
    # to redirect all subdomains use *.yourdomain.com instead of www.yourdomain.com
    server_name *.gamengineers.co;
    return 301 http://gamengineers.co$request_uri;
}

When I run curl -I gamengineers.co - I get -

 curl -I gamengineers.co
HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Sun, 22 May 2016 06:50:28 GMT
Connection: keep-alive
Location: https://gamengineers.co/
Access-Control-Allow-Origin: *

Kinda lost and chasing my tail now, anyone see something that makes sense?

1 Answer

Hi @ghostrunners,

It looks like you may have already resolved the problem, but let us know if you haven't and if you need any further assistance!

Have another answer? Share your knowledge.