A
A
Alexey Yarkov2016-06-21 14:43:55
Nginx
Alexey Yarkov, 2016-06-21 14:43:55

How to host multiple sites on the same ip?

There is VDS. 2 applications on Node.js are spinning. In front of them is Nginx. There is a domain with an SSL certificate, and now one application is available through the domain, and the second is available via IP:PORT. I bought a domain for the second application (no SSL yet) and I'm trying to update the Nginx config, but something doesn't take off...

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
  worker_connections 1024;
  multi_accept on;
}

http {
  sendfile on;
  
  access_log  /var/log/nginx/access.log;
  error_log  /var/log/nginx/error.log  crit;

  gzip on;
  gzip_disable "msie6";
  gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

  server {
    listen 80;
    server_name domen1.ru www.domen1.ru;
    return 301 https://$server_name$request_uri;
  }

  server {
    listen       443 ssl http2;
    server_name  domen1.ru www.domen1.ru;
    ..........

    location / {
      proxy_pass http://localhost:8080;
      proxy_http_version 1.1;
      ...........
    }
  }

  # И вот эта секция не работает
  server {
    listen 80;
    server_name domen2.ru www.domen2.ru;

    location / {
      proxy_pass http://localhost:3000;
      proxy_http_version 1.1;
      ...........
    }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2016-06-21
@yarkov

DNS has not been updated, so it does not work =) Thank you all for your comments.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question