I haven't been able to figure out why I'm getting this error:
nginx: [warn] conflicting server name "stage.mydomain.com" on 0.0.0.0:80, ignored nginx: [warn] conflicting server name "stage.mydomain.com" on 0.0.0.0:443, ignored
My sites-enabled symlink file looks like. I'm not super familiar with this but I'm the only one that has any knowledge on servers. This was copied over from production. I see that port 80 and 443 are duplicated but there are some configuration differences in each block.
server {
listen 80;
server_name stage.mydomain.com;
return 301 https://stage.mydomain.com$request_uri$is_args;
}
server {
listen 80;
server_name stage.mydomain.com;
location '/.path/here' {
default_type "text/plain";
root /home/username/www/app_name/current/public;
}
return 301 https://stage.mydomain.com$request_uri$is_args;
}
server {
listen 443;
ssl on;
ssl_certificate /a/path/to/my/file.pem;
ssl_certificate_key /a/path/to/my/key.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
##ssl_ciphers HIGH:!aNULL:!MD5;
ssl_ciphers "randomstuffhere";
ssl_prefer_server_ciphers on;
client_max_body_size 32000M;
server_name stage.mydomain.com;
return 301 https://stage.mydomain.com$request_uri;
}
server {
listen 443;
ssl on;
ssl_certificate /a/path/to/my/file.pem;
ssl_certificate_key /a/path/to/my/key.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
##ssl_ciphers HIGH:!aNULL:!MD5;
ssl_ciphers "randomstuffhere";
ssl_prefer_server_ciphers on;
client_max_body_size 32000M;
server_name stage.mydomain.com;
root /home/username/www/app_name/current/public; # <--- be sure to point to 'public'!
passenger_enabled on;
rails_env staging;
}
You cant have 2 server statements using the same server_name. Nginx wouldnt know which one to use if a request comes in, since both share the same virtual host name. Thus nginx will use the first match.
From your config sniplet it seems you can drop the 2nd server port 80 statement, as the root dir is useless since you are doing a redirect anyway (which is the same for the first server statement)
Also drop the first server 443 statement, as this would cause a redirect loop to itself.