0

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 :

MyOtherDomain

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 / {
          proxy_pass http://127.0.0.1:3000;

sub_MyMainDomain

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;
}

Nginx.conf

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

Phung D. An
  • 150
  • 8

1 Answers1

5

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
}
Alexander Tolkachev
  • 4,608
  • 3
  • 14
  • 23