[ysrock@centos7 ~]$ sudo certbot delete Saving debug log to /var/log/letsencrypt/letsencrypt.log Which certificate(s) would you like to delete? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: hogehoge.com 2: reminder.ysrock.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deleted all files relating to certificate reminder.ysrock.com. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
既に設定済みのドメイン一覧が表示されるので
削除したいドメインの番号を入力する。
今回は2とタイプしてエンターを押した。
念のため、/etc/letsencrypt/配下のディレクトリを見てみたら
ちゃんと削除されていた。
Zabbixのダッシュボードを開くと次の障害が表示されていた。
「Nginx: Failed to fetch stub status page」
stub status page からの読み込みに失敗しているようなので
Nginxのログを確認してみる。
$ sudo tail -f /var/log/nginx/access.log
::1 – – [26/Apr/2022:16:18:43 +0900] “GET /basic_status HTTP/1.1” 404 3971 “-” “Zabbix 6.0.3” “-“
404エラーが表示されている。
ん?
::1??
IPv6やん!
NginxではIPv6の設定を行っていないので、これが原因。
IPv6を無効にすると色々面倒な事になりそうなので
ZabbixからIPv4で見に行ってもらおう。
まずは、Nginxのconfに127.0.0.1を追加
server { server_name localhost 127.0.0.1; }
Nginxを再起動する。
Zabbixを開いて 設定 > テンプレート にある「Nginx by Zabbix agent」をクリック。
マクロタブの{$NGINX.STUB_STATUS.HOST}の値を
「localhost」から「127.0.0.1」に変更する。
これでZabbixからIPv4でNginxにアクセスしてくれるようになった。
]]>このエラーが出た時は、大きなデータを送信してしまった時。
なのでclient_max_body_sizeを変えれば良いと思ってた。
値を大きくして、nginxをrestartしても413エラーが出る。
なぜだ???
nginxのproxyを立てていたのが原因だった。
ブラウザからアクセスすると、まずproxyサーバのnginxに繋がり、
そこから別サーバへ転送がかかる。
なので、proxyサーバのnginxと、webサーバのnginxの両方設定する必要があった。
既に多くのドメインで運用中だが、
それらすべてのconfを変更する必要がある。
sudo systemctl restart nginx.service
で再起動が出来なかったのでログを確認
$systemctl status nginx.service nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 64
nginx.confをいじります
sudo vi /etc/nginx/nginx.conf http { server_names_hash_bucket_size 128; }]]>
・プロキシサーバでLet’s EncryptのSSL証明書を発行
・プロキシサーバとWEBサーバ間はhttpで通信
・Nginxを使用している
プロキシサーバのnginxコンフィグに追記
server { listen 443; proxy_set_header X-Forwarded-Proto https; }]]>
$ sudo dnf install -y nginx インストール: nginx x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream 570 k 依存関係のインストール: nginx-all-modules noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream 23 k nginx-filesystem noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream 24 k nginx-mod-http-image-filter x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream 35 k nginx-mod-http-perl x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream 45 k nginx-mod-http-xslt-filter x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream 33 k nginx-mod-mail x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream 64 k nginx-mod-stream x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream 85 k モジュールストリームの有効化中: nginx 1.14
php8のインストール
$ dnf module list php --enablerepo=epel --enablerepo=remi-safe CentOS Stream 8 - AppStream Name Stream Profiles Summary php 7.2 [d] common [d], devel, minimal PHP scripting language php 7.3 common [d], devel, minimal PHP scripting language php 7.4 common [d], devel, minimal PHP scripting language Remi's Modular repository for Enterprise Linux 8 - x86_64 Name Stream Profiles Summary php remi-7.2 common [d], devel, minimal PHP scripting language php remi-7.3 common [d], devel, minimal PHP scripting language php remi-7.4 common [d], devel, minimal PHP scripting language php remi-8.0 common [d], devel, minimal PHP scripting language $ sudo dnf module reset php $ sudo dnf module install -y php:remi-8.0
いつも通り、バーチャルホストにPHPの記述を加えたら502エラーが表示された。
location ~ \.(php|html)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
この時のエラーログ
2021/06/09 05:13:24 [error] 1739#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.29.240.1, server: hogehoge.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "hogehoge.com"
どうやらphp-fpmへのパスが通ってない模様
/etc/php-fpm.d/www.conf
listen = /run/php-fpm/www.sock
fastcgi_pashを変更する
# fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/run/php-fpm/www.sock;
あとは、再起動
$ sudo systemctl restart php-fpm $ sudo systemctl restart nginx.service]]>
map $http_origin $cors{ "https://hoge.jp" $http_origin; "https://xyzzy.com" $http_origin; } server{ add_header Access-Control-Allow-Origin $cors; }]]>
$ sudo vi /usr/local/nginx/conf/nginx.conf http{ server{ location / { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "POST, GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, Authorization, Accept"; add_header Access-Control-Allow-Credentials true; } } }]]>
$ sudo vi /usr/local/nginx/conf/mime.types types { application/x-mpegURL m3u8; video/MP2T ts; }
パスが不明の場合は、次のコマンドで検索
$ sudo find / -name mime.types]]>