1 つのアプリケーションと複数のドメイン向けの NginX を使用した Docker ベース

1 つのアプリケーションと複数のドメイン向けの NginX を使用した Docker ベース

私は自分のサイトを実行するために、nginx イメージと docker を使用しています。

次のような構成になっています:

ドッカー

version: '7.1'

services:
  #
  # Conflicts with any local HTTP server.
  # If you have a local Nginx, you must stop it.
  #
  nginx:
    image: nginx:1.12.0-alpine
    container_name: nginx
    ports:
      - "80:80"
    volumes:
      - ./files/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./files/nginx/sites-enabled:/etc/nginx/sites-enabled:ro
    network_mode: bridge

サイト 1.conf

upstream site-one.local {
  server host.docker.internal:9293 fail_timeout=0;
}

server {
  listen 80;
  server_name site-one.local *.site-one.local;

  client_max_body_size 50M;
  error_page 500 502 503 504 /50x.html;

  location = /50x.html {
    root html;
  }

  try_files $uri/index.html $uri @site-one.local;
  location @site-one.local {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://site-one.local;
  }
}

Web アプリケーションにタブがあり、クリックすると新しいドメイン名でページが開きsite-two.local/my-page、エラーが返されます。

このサイトは site-two.local に接続できません。接続を拒否されました。

site-two.local同じアプリケーションに追加のドメインを追加するにはどうすればいいですか?

答え1

同じアプリケーションに追加のドメイン site-two.local を追加するにはどうすればよいですか?

設定を変更するとserver_name機能するはずです...ただし、このエラーが nginx によって発生したのか、アプリケーションによって発生したのかはわかりません。

  server_name site-one.local *.site-one.local site-two.local *.site-two.local;

server {...site-two.local 用に別のブロックを作成しても機能する可能性があります。

関連情報