My question is quite different than thousand of similar questions out there.

I have 2 dedicated servers. The stronger one is serving MyMainDomain.com

My weaker server but huge hard drive is hosting MyOtherDomain.com and also images in sub domain of my main domain above, lets say : sub.MyMainDomain.com. This server has 2 IP. If both MyOtherDomain.com and sub.MyMainDomain.com are listen on same IP, MyOtherDomain.com will break. Solved if listen on different IP.... But that is NOT right ! We need both of them to work on 1 IP.

Nginx version: nginx/1.13.8

Symlink in /etc/nginx/sites-enabled :


server {

    listen IP_1:443 ssl http2; 
    server_name MyOtherDomain.com; # this domain must match Common Name (CN) in the SSL certificate
    # pass all requests to Meteor
    location / {


server {

    listen IP1:443 ssl;    # error
    listen IP2:443 ssl;    # work fine
    server_name sub.MyMainDomain.com ;

  # proxy pass to minio 
  location / {
   proxy_set_header Host $http_host;
   proxy_pass http://IP1 or IP2:9000;


server { # this block is useless, googling sometime does not help
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server; # not sure if you want/need it here as well. Try both ways.

    server_name _;
     return 444;

# Virtual Host Configs

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;


All domains are protected by cloudflare DNS with allocated IP :

MyMainDomain.com : IP_0

MyOtherDomain.com and sub.MyMainDomain.com share IP_1 preferable

IP_2 is needed somewhere else

  • Aw man, why down vote me.. – Phung D. An Dec 30 '17 at 19:50

Don't listen on IP. Just listen on all addresses. For example:

server {

    listen 443  ssl http2;

    server_name MyOtherDomain.com

server {

    listen 443  ssl http2;

    server_name sub.MyOtherDomain.com
| improve this answer | |
  • No, that won't work, [https]://MyOtherDomain.com will display the content of sub.MainDomain.com – Phung D. An Dec 30 '17 at 19:46
  • This is correct. If you still see the wrong content, the problem lies elsewhehre. – Michael Hampton Dec 30 '17 at 19:57
  • @PhamH.An this config works for me. Have you restarted nginx after configuration change? Sometimes reload not work. – Alexander Tolkachev Dec 30 '17 at 19:58
  • Guys, thanks for your help, I guess Cloudflare server DOES mess things up. I will upvote your answer but can not accept it. – Phung D. An Dec 30 '17 at 20:17
  • You should have mentioned Cloudflare in the question in the first place, since that is crucial information in order to provide a good answer. – Tero Kilkanen Dec 31 '17 at 2:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.