お世話になります
2つのサブドメインサーバ「huga.aaa.jp」「hoge.aaa.jp」のセットアップが完了しまして
SSLで接続し「$_SERVER — サーバー情報および実行時の環境情報」を確認したところ
SSLで接続しているにも関わらず、PHPのサーバー情報が非SSLであるという値になってしまいます
具体的には「[SERVER_PORT] => 80、[REQUEST_SCHEME] => http」となります
SSLはブラウザ上でエラー等は吐いておらず、PHPだけが狂っています
SSLで接続しているにも関わらず非SSLの値になってしまうのはなにが原因なのでしょうか
CentOS Linux release 7.9.2009 (Core)
Server version: Apache/2.4.6 (CentOS)
Server built: Nov 16 2020 16:18:20
PHP 7.4.16 (cli) (built: Mar 2 2021 10:35:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
print_r($_SERVER); Array ( [HTTP_HOST] => huga.aaa.jp [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => ja,en-US;q=0.7,en;q=0.3 [HTTP_ACCEPT_ENCODING] => gzip, deflate, br [HTTP_CONNECTION] => keep-alive [SERVER_SOFTWARE] => Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.16 [SERVER_NAME] => huga.aaa.jp [SERVER_PORT] => 80 [DOCUMENT_ROOT] => /var/www/html/huga/ [REQUEST_SCHEME] => http [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 )
セットアップ情報
PHP7.4をインストール
yum -y update && \ yum -y install epel-release mod_ssl openssl && \ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm && \ yum install -y --enablerepo=remi,remi-php74 php php-devel php-mysql php-gd php-mbstring php-pear php-imap php-xmlrp php-xml php-pgsql php-mcrypt && \ systemctl start httpd.service && \ systemctl enable httpd.service && \
非SSLバーチャルホスト設定
vi /etc/httpd/conf/httpd.conf <VirtualHost *:80> ServerName huga.aaa.jp DocumentRoot "/var/www/html/huga/" </VirtualHost> <VirtualHost *:80> ServerName hoge.aaa.jp DocumentRoot "/var/www/html/hoge/" </VirtualHost> systemctl restart httpd
レッツエンクリプト設定
yum -y install snapd && \ systemctl enable --now snapd.socket && \ ln -s /var/lib/snapd/snap /snap && \ systemctl start snapd.seeded.service && \ snap install --classic certbot && \ sudo ln -s /snap/bin/certbot /usr/bin/certbot && \ certbot certonly --webroot -w /var/www/html/huga -d huga.aaa.jp -w /var/www/html/hoge -d hoge.aaa.jp
SSLバーチャルホスト設定
vi /etc/httpd/conf.d/ssl.conf SSLCertificateFile /etc/letsencrypt/live/huga/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/huga/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/huga/chain.pem <VirtualHost *:443> ServerName huga.aaa.jp DocumentRoot "/var/www/html/huga/" </VirtualHost> <VirtualHost *:443> ServerName hoge.aaa.jp DocumentRoot "/var/www/html/hoge/" </VirtualHost> systemctl restart httpd
configは正しいか
apachectl configtest Syntax OK
DUMP_VHOSTS
httpd -D DUMP_VHOSTS VirtualHost configuration: *:443 is a NameVirtualHost default server XXX.sakura.ne.jp (/etc/httpd/conf.d/ssl.conf:56) port 443 namevhost XXX.sakura.ne.jp (/etc/httpd/conf.d/ssl.conf:56) port 443 namevhost huga.aaa.jp (/etc/httpd/conf.d/ssl.conf:221) port 443 namevhost hoge.aaa.jp (/etc/httpd/conf.d/ssl.conf:226) *:80 is a NameVirtualHost default server XXX.XXX.XXX.XXX (/etc/httpd/conf/httpd.conf:356) port 80 namevhost XXX.XXX.XXX.XXX (/etc/httpd/conf/httpd.conf:356) port 80 namevhost hoge.aaa.jp (/etc/httpd/conf/httpd.conf:366) port 80 namevhost huga.aaa.jp (/etc/httpd/conf/httpd.conf:371)
htaccessは効いていないか
なし