nginx設定ファイルのserver_nameはどのように機能しますか?

nginx設定ファイルのserver_nameはどのように機能しますか?

私はフォローしていますhttps://gist.github.com/mcxiaoke/055af99e86f8e8d3176e

server {
  # Git repos are browsable at http://example.com:4321/
  listen 4321 default;   # Remove 'default' from this line if there is already another server running on port 80
  server_name example.com;

  location /index.cgi {
    root /usr/share/gitweb/;
    include fastcgi_params;
    gzip off;
    fastcgi_param SCRIPT_NAME $uri;
    fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
  }

  location / {
    root /usr/share/gitweb/;
    index index.cgi;
  }
}

私のWebブラウザが次に接続するのはなぜですか?http://example.com:4321/すぐに接続できますが、永遠にhttp://localhost:4321/


解決策が見つかりましたhttps://unix.stackexchange.com/a/188193/674:私のアイテムに追加/etc/hosts

127.0.0.1 localhost www.example.net

www.example.netGoogle Chrome では接続できますが、Firefox では接続できません。

セキュア接続の失敗

www.example.com:4321 接続中にエラーが発生しました。 SSLが許可された最大長を超えるレコードを受信しました。エラーコード:SSL_ERROR_RX_RECORD_TOO_LONG

The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem.

アドレスバーのURLは常に「https://www.example.com:4321/「貼り付けるときwww.example.com:4321/

この変更がChromeに適用されるのはなぜですか? Firefoxにはなぜできないのですか?

ありがとうございます。

ベストアンサー1

私が説明したように、ホストの解析を設定する必要があります。このQ&A

About server_namenginx同じIP、同じポートを受信する仮想ホストを作成するオプションとして提供されます。これらを区別する唯一の方法は、ホスト名解決を通じてです。 Webホスティングの詳細を確認できます。server_name ここ

Firefoxで書くことができます。http://www.example.com:4321 また、確認することができますこのQ&A

おすすめ記事