0

这是我的第一个启用站点的文件

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


这是第二个

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


要归档的文件使用相同的 server_name,因为我想做微前端,所以第二个应用程序将在 www.cobanextwithzone.test/thesecondapp/ 上提供

问题是什么时候sudo service nginx restartsudo service nginx reload它显示在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

任何人都知道如何在同一个 server_name 上提供 2 个应用程序?

谢谢!

4

0 回答 0