NGINX: configure multiple ports on a single server or domain name

Hi guys I'm new to nginx. I'm having problems with my setup, I want my server to start up with multiple ports in public.

For Ex:

server {
  listen 443 ssl;
  server_name <https - mydomainname>;
  ssl_certificate <location cert>;
  ssl_certificate_key <location key>;
    location /tags.txt {
      add_header 'Access-Control-Allow-Origin' '*';
    }
}

From the setting above, I can now access completely. But what if I have http: // localhost: 6006 and http: // localhost: 5005 have several ports in my local host and I want to publish it. I tried to access it using this https - mydomainname: port 6006 and https - mydomainname: port 5005, but it does not work.

Should I create a setting for another port? As for port 6006

server {
 listen 6006 ssl;
 server_name <https - mydomainname>;
 ssl_certificate <location cert>;
 ssl_certificate_key <location key>;
  location /tags.txt {
    add_header 'Access-Control-Allow-Origin' '*';
    proxy_pass http://localhost:6006;
  }
}

and port 5005

server {
 listen 5005 ssl;
 server_name <https - mydomainname>;
 ssl_certificate <location cert>;
 ssl_certificate_key <location key>;
  location /tags.txt {
    add_header 'Access-Control-Allow-Origin' '*';
    proxy_pass http://localhost:5005;
  }
}

I have no idea how to fix this. Any help is greatly appreciated.

+4
2

listen server:

server {
 listen 5005 ssl;
 listen 6006 ssl;
 server_name <https - mydomainname>;
 ssl_certificate <location cert>;
 ssl_certificate_key <location key>;
  location /tags.txt {
    add_header 'Access-Control-Allow-Origin' '*';
  }
}
+7

.

server_part , fqdn.

server {
 listen 5005 ssl;
 listen 6006 ssl;
 server_name <https - mydomainname>;
 server_name <https - mydomainname>;
 ssl_certificate <location cert>;
 ssl_certificate_key <location key>;
  location /tags.txt {
    add_header 'Access-Control-Allow-Origin' '*';
  }
}

.

0

All Articles