0

I'm deploying a website with a jar file. This is my first server that I've set up, so I'm a bit lost on what to do here. I have this in my nginx.config:

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

server {
     listen       80;
     server_name  mySite.com;

      location / {
           proxy_pass http://localhost:3000 ;
      }

      .....

I set up the CNAME according to the documentation.

I've tried several resources to straighten this out:

http://nginx.org/en/docs/http/converting_rewrite_rules.html

Nginx no-www to www and www to no-www

http://rtcamp.com/wordpress-nginx/tutorials/nginx/www-non-www-redirection/

And keep getting the same error:

$ systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Fri 2013-09-27 06:22:30 UTC; 11s ago
  Process: 4492 ExecStop=/usr/bin/nginx -g pid /run/nginx.pid; -s quit (code=exited, status=1/FAILURE)
  Process: 3705 ExecStart=/usr/bin/nginx -g pid /run/nginx.pid; daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 4495 ExecStartPre=/usr/bin/nginx -t -q -g pid /run/nginx.pid; daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 3706 (code=exited, status=0/SUCCESS)
   CGroup: name=systemd:/system/nginx.service
Community
  • 1
  • 1
dizzystar
  • 1,055
  • 12
  • 22

1 Answers1

0

I found a solution. Turns out that I don't need to add a second server:

server {
     listen       80;
     server_name  mySite.com www.mySite.com;

      location / {
           proxy_pass http://localhost:3000 ;
      }

I'm not sure if this the the absolute correct answer, but I did try this example from nginx.com and it did not work:

server {
    listen       80;
    server_name  example.com www.example.com;
    ...
}

server {
    listen       80 default_server;
    server_name  _;
    return       301 http://example.com$request_uri;
}
dizzystar
  • 1,055
  • 12
  • 22