作業記録:nginxとWebサイト、DNSキャッシュ

nginxのインストールと設定は、セットアップスクリプトで完了。念の為にセットアップスクリプトは:

#!/bin/sh
# -*- coding: utf-8-unix -*-

# Data files:
# - nginx_server.conf.templ
# - nginx_404.html
# - nginx_index.html

start_message nginx

_source_must ./nginx.conf.sh

if need_install_missing_file /etc/nginx/nginx.conf ; then
    yum -y install nginx
    creation_log "nginx installed"
fi

show_env PROV_FORCE_CONFIG

if need_config_missing_file /etc/nginx/conf.d/server$NGINX_FILE_SUFFIX.conf; then
    sed \
        -e "s#@@NGINX_SERVER_NAME@@#$NGINX_SERVER_NAME#g" \
        -e "s#@@NGINX_ROOT@@#$NGINX_ROOT#g" \
        $RUNTIME_PROV_DIR/nginx_server.conf.templ > /etc/nginx/conf.d/server$NGINX_FILE_SUFFIX.conf
    creation_log "file: /etc/nginx/conf.d/server$NGINX_FILE_SUFFIX.conf"
    message /etc/nginx/conf.d/server$NGINX_FILE_SUFFIX.conf created
else
    message /etc/nginx/conf.d/server$NGINX_FILE_SUFFIX.conf NOT updated
fi

if dir_not_exist $NGINX_ROOT; then
    mkdir -p $NGINX_ROOT
    creation_log "dir: $NGINX_ROOT"
fi

cp_unless ./nginx_404.html   $NGINX_ROOT/404.html

cp_unless ./nginx_index.html $NGINX_ROOT/index.html

chmod +x $NGINX_ROOT

unset_service httpd

set_service nginx

firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload

このスクリプトで作られた /etc/nginx/conf.d/server-daphnia.conf ("$NGINX_FILE_SUFFIX" = "-daphia")は単純なもので、

    # -*- coding: utf-8-unix
    # www.daphnia.org
    #
    server {
        listen       80;
        server_name  www.daphnia.org;
        access_log  /var/log/nginx/www.daphnia.org.access.log  main;

        location / {
            root   /home/hiyama/web_pub;
            index  index.html index.htm;
        }

        error_page  404              /404.html;
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
          root   /usr/share/nginx/html;
        }
    }

しかし、これだけでも十分で、chimairaサイトを提供できる(はず)。

現状では、daphnia.org のDNS情報はけっこう浸透しているが、ブラウザがDNS情報のローカルキャッシュをしているらしくて、古い http://daphnia.org/ (タブ郎) が見えている。キャッシュしてないEdgeで見たら新しい http://daphnia.org/ が見えた。これは、Welcome to nginx on AlmaLinux! のテストページ。

http://www.daphnia.org/ だとなぜか Cloudflare のエラーメッセージが出る。要調査。

What happened?
The initial connection between Cloudflare's network and the origin web server timed out. As a result, the web page can not be displayed.

What can I do?
If you're a visitor of this website:
Please try again in a few minutes.

If you're the owner of this website:
Contact your hosting provider letting them know your web server is not completing requests. An Error 522 means that the request was able to connect to your web server, but that the request didn't finish. The most likely cause is that something on your server is hogging resources. Additional troubleshooting information here.

別なタイミングでの Firefox に対する http://www.daphnia.org/ のエラーは:

403 Forbidden
nginx/1.14.1

nginx 1.14.1 ということはConoHaサーバーに向かっている。ConoHaサーバーのnginxの設定で何とかなるだろう。

ところで、キャッシュされてない Edge を使うのはよいが、次のメッセージが出た。

URL をコピーしたときの貼り付けには、既定では実際の URL ではなく URL のわかりやすいリンク (ページのタイトル) が使用されます。
実際の URL を貼り付ける場合は、Ctrl+Shift+V を使用してください
コピーと貼り付けの既定の形式を実際の URL に設定する場合は、[既定値の変更] を選択します。

なんとやっかいな時代だ。おそらく日本語URLとか http: と https: の部分をアドレスバー表示で意識させないためだろうが、設定確認しているときは厄介。既定値を変更した。

DNSキャッシュについては:

アプリケーションレベルならまだしもOSでキャッシュされていると困るので、PowerShellで:

> ipconfig /displaydns
> ipconfig /flushdns

ipconfig /displaydns の結果は:

daphnia.org 関連:

    www.daphnia.org
    ----------------------------------------
    レコード名 . . . . . . . : www.daphnia.org
    レコードの種類 . . . . . : 1
    Time To Live  . . . . . .: 2503
    データの長さ . . . . . . : 4
    セクション . . . . . . . : 回答
    A (ホスト) レコード. . . : 160.251.23.194


    daphnia.org
    ----------------------------------------
    レコード名 . . . . . . . : daphnia.org
    レコードの種類 . . . . . : 1
    Time To Live  . . . . . .: 415
    データの長さ . . . . . . : 4
    セクション . . . . . . . : 回答
    A (ホスト) レコード. . . : 160.251.23.194

chimaira.org 関連:

    www.chimaira.org
    ----------------------------------------
    レコード名 . . . . . . . : www.chimaira.org
    レコードの種類 . . . . . : 1
    Time To Live  . . . . . .: 1875
    データの長さ . . . . . . : 4
    セクション . . . . . . . : 回答
    A (ホスト) レコード. . . : 153.122.38.158


    www.chimaira.org
    ----------------------------------------
    レコード名 . . . . . . . : www.chimaira.org
    レコードの種類 . . . . . : 28
    Time To Live  . . . . . .: 1875
    データの長さ . . . . . . : 16
    セクション . . . . . . . : 回答
    AAAA レコード. . . . . . : 2001:260:306:b::997a:269e


    www.chimaira.org
    ----------------------------------------
    レコード名 . . . . . . . : www.chimaira.org
    レコードの種類 . . . . . : 28
    Time To Live  . . . . . .: 1875
    データの長さ . . . . . . : 16
    セクション . . . . . . . : 回答
    AAAA レコード. . . . . . : 2001:260:306:b::997a:269e


    www.chimaira.org
    ----------------------------------------
    レコード名 . . . . . . . : www.chimaira.org
    レコードの種類 . . . . . : 1
    Time To Live  . . . . . .: 1875
    データの長さ . . . . . . : 4
    セクション . . . . . . . : 回答
    A (ホスト) レコード. . . : 153.122.38.158