0

This is my first sites-enabled file

server {
  listen 80;
  listen 443 ssl;

  server_name www.cobanextwithzone.test;

  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_min_length 256;
  gzip_types
    text/plain
    text/css
    application/json
    application/x-javascript
    text/xml
    application/xml
    application/xml+rss
    text/javascript
    application/javascript
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/font-woff
    font/opentype
    image/svg+xml
    image/x-icon;

  ssl_certificate /etc/nginx/ssl/server.crt;
  ssl_certificate_key /etc/nginx/ssl/server.key;

  location / {
    proxy_set_header Host $http_host;
    proxy_pass http://localhost:3000;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}


and this is the second

server {
  listen 80;
  listen 443 ssl;

  server_name www.cobanextwithzone.test;

  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_min_length 256;
  gzip_types
    text/plain
    text/css
    application/json
    application/x-javascript
    text/xml
    application/xml
    application/xml+rss
    text/javascript
    application/javascript
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/font-woff
    font/opentype
    image/svg+xml
    image/x-icon;

  ssl_certificate /etc/nginx/ssl/server.crt;
  ssl_certificate_key /etc/nginx/ssl/server.key;

  location / {
    proxy_set_header Host $http_host;
    proxy_pass http://localhost:3000;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}


those to file are using same server_name, because I wanted to do microfrontends, so the second app will be served on www.cobanextwithzone.test/thesecondapp/

the problem is when sudo service nginx restart or sudo service nginx reload it shows this on sudo nginx -t

nginx: [warn] conflicting server name "www.cobanextwithzone.test" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.cobanextwithzone.test" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.cobanextwithzone.test" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.cobanextwithzone.test" on 0.0.0.0:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Anyone know how to serve 2 app on same server_name?

Thanks!

William Lim
  • 11
  • 1
  • 3
  • In Nginx `/thesecondapp/` belongs in a `location` statement. Two apps served from the same port and `server_name` are served from the same `server` block. The separation of URIs is handled by the `location` blocks within it. – Richard Smith May 12 '20 at 09:32
  • oh yeah, /thesecondapp/ is handled by the app, but it still 2 different app, and need to deployed on same server_name, have any idea how to serve 2 app with same server_name? – William Lim May 12 '20 at 10:05

0 Answers0