linux:httpd:virtualhost_sni_redirect

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
linux:httpd:virtualhost_sni_redirect [2019/02/19 00:16] – 作成 ともやんlinux:httpd:virtualhost_sni_redirect [2023/06/01 05:55] (現在) – [Apache 全体の SSL の設定] ともやん
行 8: 行 8:
   * 複数の SSL 証明書を取得済みである事   * 複数の SSL 証明書を取得済みである事
  
 +<WRAP prewrap 100% #mintbl>
 ^  ユーザーアクセスパターン  ^  Apache の動作  ^ ^  ユーザーアクセスパターン  ^  Apache の動作  ^
 | http://monsters-g.com  |  https://www.monsters-g.com へリダイレクト  | | http://monsters-g.com  |  https://www.monsters-g.com へリダイレクト  |
行 16: 行 17:
 | https://tomoyan.net  |  https://www.tomoyan.net へリダイレクト  | | https://tomoyan.net  |  https://www.tomoyan.net へリダイレクト  |
 | http://repos.tomoyan.net  |  https://repos.tomoyan.net へリダイレクト  | | http://repos.tomoyan.net  |  https://repos.tomoyan.net へリダイレクト  |
 +</WRAP>
  
-===== 最初の設定内容(問題の発生する設定) ===== +===== 最終的な設定内容(問題の発生しない設定) ===== 
-結論から言うと以下設定法では問題発生ました。\\ +Apache は Rewrite より Redirect の方が処理とては軽い。\\ 
-なぜか https://monsters-g.com のユーザーアクセスパターンの時だけ、Apache が tomoyan.net の SSL 証明書を使って通信を暗号化しようとす現象が発生し、原因不明で悩みました。+Rewrite するだけの処理であったとしても SSL 証明書の指定は必要であ。もも証明書を指定しなかった場合は全体的に原因不明な変な動作を引き起こした。\\
  
 ==== Apache 全体の SSL の設定 ==== ==== Apache 全体の SSL の設定 ====
-<code> +<code> 
-$ sudo vi /etc/httpd/conf.d/ssl.conf +$ sudo vi /etc/httpd/conf.d/ssl.conf 
-</code> +</code> 
-<file autoconf /etc/httpd/conf.d/ssl.conf>+<file autoconf /etc/httpd/conf.d/ssl.conf>
 # SNIに未対応のブラウザ用の設定 # SNIに未対応のブラウザ用の設定
 SSLStrictSNIVHostCheck off SSLStrictSNIVHostCheck off
-</file>+</file>
  
-==== monsters-g.com SSL の設定(問題の発生する設定) ====+==== monsters-g.com SSL の設定 ==== 
 +Apache のバーチャルホストの設定。\\
 <code> <code>
 $ sudo vi /etc/httpd/conf.d/www.monsters-g.com.conf $ sudo vi /etc/httpd/conf.d/www.monsters-g.com.conf
 </code> </code>
 +<WRAP prewrap 100%>
 <file autoconf /etc/httpd/conf.d/www.monsters-g.com.conf> <file autoconf /etc/httpd/conf.d/www.monsters-g.com.conf>
-<VirtualHost *:80 *:443> 
-    ServerName monsters-g.com 
-    RewriteEngine on 
-    RewriteCond %{HTTP_HOST} ^monsters-g\.com 
-    RewriteRule ^/(.*)$ https://www.monsters-g.com/$1 [R=301,L] 
-</VirtualHost> 
 <VirtualHost *:80> <VirtualHost *:80>
     ServerName www.monsters-g.com     ServerName www.monsters-g.com
-    RewriteEngine on +    ServerAlias monsters-g.com 
-    RewriteCond %{HTTP_HOST} ^www\.monsters-g\.com +    Redirect "/" "https://www.monsters-g.com/"
-    RewriteRule ^/(.*)$ https://www.monsters-g.com/$1 [R=301,L]+
 </VirtualHost> </VirtualHost>
 <VirtualHost *:443> <VirtualHost *:443>
     DocumentRoot "/var/www/vhosts/www.monsters-g.com"     DocumentRoot "/var/www/vhosts/www.monsters-g.com"
     ServerName www.monsters-g.com     ServerName www.monsters-g.com
 +    ServerAlias monsters-g.com
 +
 +    RewriteEngine on
 +    RewriteCond %{HTTP_HOST} ^monsters-g\.com
 +    RewriteRule ^/(.*)$ https://www.monsters-g.com/$1 [R=301,L]
 +
 +    SSLEngine on
 +    SSLProtocol all -SSLv2 -SSLv3
 +    SSLCipherSuite !3DES:!aNULL:EDH+HIGH:ECDH+HIGH:-AES128:-3DES:-DSS:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA
 +    SSLHonorCipherOrder on
     SSLCertificateFile /etc/letsencrypt/live/monsters-g.com/cert.pem     SSLCertificateFile /etc/letsencrypt/live/monsters-g.com/cert.pem
     SSLCertificateKeyFile /etc/letsencrypt/live/monsters-g.com/privkey.pem     SSLCertificateKeyFile /etc/letsencrypt/live/monsters-g.com/privkey.pem
行 61: 行 68:
 </VirtualHost> </VirtualHost>
 </file> </file>
 +</WRAP>
  
-==== tomoyan.net SSL の設定(問題の発生する設定) ====+==== tomoyan.net SSL の設定 ====
 <code> <code>
 $ sudo vi /etc/httpd/conf.d/www.tomoyan.net.conf $ sudo vi /etc/httpd/conf.d/www.tomoyan.net.conf
 </code> </code>
 +<WRAP prewrap 100%>
 <file autoconf /etc/httpd/conf.d/www.tomoyan.net.conf> <file autoconf /etc/httpd/conf.d/www.tomoyan.net.conf>
-<VirtualHost *:80 *:443> 
-    ServerName tomoyan.net 
-    RewriteEngine on 
-    RewriteCond %{HTTP_HOST} ^tomoyan\.net 
-    RewriteRule ^/(.*)$ https://www.tomoyan.net/$1 [R=301,L] 
-</VirtualHost> 
 <VirtualHost *:80> <VirtualHost *:80>
     ServerName www.tomoyan.net     ServerName www.tomoyan.net
-    RewriteEngine on +    ServerAlias tomoyan.net 
-    RewriteCond %{HTTP_HOST} ^www\.tomoyan\.net +    Redirect "/" "https://www.tomoyan.net/"
-    RewriteRule ^/(.*)$ https://www.tomoyan.net/$1 [R=301,L]+
 </VirtualHost> </VirtualHost>
 <VirtualHost *:443> <VirtualHost *:443>
     DocumentRoot "/var/www/vhosts/www.tomoyan.net/dokuwiki"     DocumentRoot "/var/www/vhosts/www.tomoyan.net/dokuwiki"
     ServerName www.tomoyan.net     ServerName www.tomoyan.net
 +    ServerAlias tomoyan.net
 +
 +    RewriteEngine on
 +    RewriteCond %{HTTP_HOST} ^tomoyan\.net
 +    RewriteRule ^/(.*)$ https://www.tomoyan.net/$1 [R=301,L]
 +
 +    SSLEngine on
 +    SSLProtocol all -SSLv2 -SSLv3
 +    SSLCipherSuite !3DES:!aNULL:EDH+HIGH:ECDH+HIGH:-AES128:-3DES:-DSS:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA
 +    SSLHonorCipherOrder on
     SSLCertificateFile /etc/letsencrypt/live/tomoyan.net/cert.pem     SSLCertificateFile /etc/letsencrypt/live/tomoyan.net/cert.pem
     SSLCertificateKeyFile /etc/letsencrypt/live/tomoyan.net/privkey.pem     SSLCertificateKeyFile /etc/letsencrypt/live/tomoyan.net/privkey.pem
行 93: 行 105:
 </VirtualHost> </VirtualHost>
 </file> </file>
 +</WRAP>
  
-==== repos.tomoyan.net SSL の設定(問題の発生する設定) ====+==== repos.tomoyan.net SSL の設定 ==== 
 +Apache のバーチャルホストの設定。\\
 <code> <code>
 $ sudo vi /etc/httpd/conf.d/repos.tomoyan.net.conf $ sudo vi /etc/httpd/conf.d/repos.tomoyan.net.conf
 </code> </code>
 +<WRAP prewrap 100%>
 <file autoconf /etc/httpd/conf.d/repos.tomoyan.net.conf> <file autoconf /etc/httpd/conf.d/repos.tomoyan.net.conf>
 <VirtualHost *:80> <VirtualHost *:80>
     ServerName repos.tomoyan.net     ServerName repos.tomoyan.net
-    RewriteEngine on +    Redirect "/" "https://repos.tomoyan.net/"
-    RewriteCond %{HTTP_HOST} ^repos\.tomoyan\.net +
-    RewriteRule ^/(.*)$ https://repos.tomoyan.net/$1 [R=301,L]+
 </VirtualHost> </VirtualHost>
 <VirtualHost *:443> <VirtualHost *:443>
     DocumentRoot "/var/www/vhosts/repos.tomoyan.net"     DocumentRoot "/var/www/vhosts/repos.tomoyan.net"
     ServerName repos.tomoyan.net     ServerName repos.tomoyan.net
 +
 +    SSLEngine on
 +    SSLProtocol all -SSLv2 -SSLv3
 +    SSLCipherSuite !3DES:!aNULL:EDH+HIGH:ECDH+HIGH:-AES128:-3DES:-DSS:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA
 +    SSLHonorCipherOrder on
     SSLCertificateFile /etc/letsencrypt/live/tomoyan.net/cert.pem     SSLCertificateFile /etc/letsencrypt/live/tomoyan.net/cert.pem
     SSLCertificateKeyFile /etc/letsencrypt/live/tomoyan.net/privkey.pem     SSLCertificateKeyFile /etc/letsencrypt/live/tomoyan.net/privkey.pem
行 119: 行 137:
 </VirtualHost> </VirtualHost>
 </file> </file>
 +</WRAP>
  
-===== 最終的な設定内容(問題の発生しない設定) ===== +===== 最初の設定内容(問題の発生する設定) ===== 
-Apache は Rewrite より Redirect の方が処理とては軽い。\\ +結論から言うと以下設定法では問題発生ました。\\ 
-Rewrite するだけの処理であったとしても SSL 証明書の指定は必要であ。もも証明書を指定しなかった場合は全体的に原因不明な変な動作を引き起こした。\\+なぜか https://monsters-g.com のユーザーアクセスパターンの時だけ、Apache が tomoyan.net の SSL 証明書を使って通信を暗号化しようとす現象が発生し、原因不明で悩みました。
  
 ==== Apache 全体の SSL の設定 ==== ==== Apache 全体の SSL の設定 ====
行 133: 行 152:
 </file> </file>
  
-==== monsters-g.com SSL の設定 ==== +==== monsters-g.com SSL の設定(問題の発生する設定) ====
-Apache のバーチャルホストの設定。\\+
 <code> <code>
 $ sudo vi /etc/httpd/conf.d/www.monsters-g.com.conf $ sudo vi /etc/httpd/conf.d/www.monsters-g.com.conf
 </code> </code>
-<WRAP prewrap 100%> 
 <file autoconf /etc/httpd/conf.d/www.monsters-g.com.conf> <file autoconf /etc/httpd/conf.d/www.monsters-g.com.conf>
 +<VirtualHost *:80 *:443>
 +    ServerName monsters-g.com
 +    RewriteEngine on
 +    RewriteCond %{HTTP_HOST} ^monsters-g\.com
 +    RewriteRule ^/(.*)$ https://www.monsters-g.com/$1 [R=301,L]
 +</VirtualHost>
 <VirtualHost *:80> <VirtualHost *:80>
     ServerName www.monsters-g.com     ServerName www.monsters-g.com
-    ServerAlias monsters-g.com +    RewriteEngine on 
-    Redirect "/" "https://www.monsters-g.com/"+    RewriteCond %{HTTP_HOST} ^www\.monsters-g\.com 
 +    RewriteRule ^/(.*)$ https://www.monsters-g.com/$1 [R=301,L]
 </VirtualHost> </VirtualHost>
 <VirtualHost *:443> <VirtualHost *:443>
     DocumentRoot "/var/www/vhosts/www.monsters-g.com"     DocumentRoot "/var/www/vhosts/www.monsters-g.com"
     ServerName www.monsters-g.com     ServerName www.monsters-g.com
-    ServerAlias monsters-g.com 
- 
-    RewriteEngine on 
-    RewriteCond %{HTTP_HOST} ^monsters-g\.com 
-    RewriteRule ^/(.*)$ https://www.monsters-g.com/$1 [R=301,L] 
- 
-    SSLEngine on 
-    SSLProtocol all -SSLv2 -SSLv3 
-    SSLCipherSuite !3DES:!aNULL:EDH+HIGH:ECDH+HIGH:-AES128:-3DES:-DSS:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA 
-    SSLHonorCipherOrder on 
     SSLCertificateFile /etc/letsencrypt/live/monsters-g.com/cert.pem     SSLCertificateFile /etc/letsencrypt/live/monsters-g.com/cert.pem
     SSLCertificateKeyFile /etc/letsencrypt/live/monsters-g.com/privkey.pem     SSLCertificateKeyFile /etc/letsencrypt/live/monsters-g.com/privkey.pem
行 169: 行 183:
 </VirtualHost> </VirtualHost>
 </file> </file>
-</WRAP> 
  
-==== tomoyan.net SSL の設定 ====+==== tomoyan.net SSL の設定(問題の発生する設定) ====
 <code> <code>
 $ sudo vi /etc/httpd/conf.d/www.tomoyan.net.conf $ sudo vi /etc/httpd/conf.d/www.tomoyan.net.conf
 </code> </code>
-<WRAP prewrap 100%> 
 <file autoconf /etc/httpd/conf.d/www.tomoyan.net.conf> <file autoconf /etc/httpd/conf.d/www.tomoyan.net.conf>
 +<VirtualHost *:80 *:443>
 +    ServerName tomoyan.net
 +    RewriteEngine on
 +    RewriteCond %{HTTP_HOST} ^tomoyan\.net
 +    RewriteRule ^/(.*)$ https://www.tomoyan.net/$1 [R=301,L]
 +</VirtualHost>
 <VirtualHost *:80> <VirtualHost *:80>
     ServerName www.tomoyan.net     ServerName www.tomoyan.net
-    ServerAlias tomoyan.net +    RewriteEngine on 
-    Redirect "/" "https://www.tomoyan.net/"+    RewriteCond %{HTTP_HOST} ^www\.tomoyan\.net 
 +    RewriteRule ^/(.*)$ https://www.tomoyan.net/$1 [R=301,L]
 </VirtualHost> </VirtualHost>
 <VirtualHost *:443> <VirtualHost *:443>
     DocumentRoot "/var/www/vhosts/www.tomoyan.net/dokuwiki"     DocumentRoot "/var/www/vhosts/www.tomoyan.net/dokuwiki"
     ServerName www.tomoyan.net     ServerName www.tomoyan.net
-    ServerAlias tomoyan.net 
- 
-    RewriteEngine on 
-    RewriteCond %{HTTP_HOST} ^tomoyan\.net 
-    RewriteRule ^/(.*)$ https://www.tomoyan.net/$1 [R=301,L] 
- 
-    SSLEngine on 
-    SSLProtocol all -SSLv2 -SSLv3 
-    SSLCipherSuite !3DES:!aNULL:EDH+HIGH:ECDH+HIGH:-AES128:-3DES:-DSS:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA 
-    SSLHonorCipherOrder on 
     SSLCertificateFile /etc/letsencrypt/live/tomoyan.net/cert.pem     SSLCertificateFile /etc/letsencrypt/live/tomoyan.net/cert.pem
     SSLCertificateKeyFile /etc/letsencrypt/live/tomoyan.net/privkey.pem     SSLCertificateKeyFile /etc/letsencrypt/live/tomoyan.net/privkey.pem
行 206: 行 215:
 </VirtualHost> </VirtualHost>
 </file> </file>
-</WRAP> 
  
-==== repos.tomoyan.net SSL の設定 ==== +==== repos.tomoyan.net SSL の設定(問題の発生する設定) ====
-Apache のバーチャルホストの設定。\\+
 <code> <code>
 $ sudo vi /etc/httpd/conf.d/repos.tomoyan.net.conf $ sudo vi /etc/httpd/conf.d/repos.tomoyan.net.conf
 </code> </code>
-<WRAP prewrap 100%> 
 <file autoconf /etc/httpd/conf.d/repos.tomoyan.net.conf> <file autoconf /etc/httpd/conf.d/repos.tomoyan.net.conf>
 <VirtualHost *:80> <VirtualHost *:80>
     ServerName repos.tomoyan.net     ServerName repos.tomoyan.net
-    Redirect "/" "https://repos.tomoyan.net/"+    RewriteEngine on 
 +    RewriteCond %{HTTP_HOST} ^repos\.tomoyan\.net 
 +    RewriteRule ^/(.*)$ https://repos.tomoyan.net/$1 [R=301,L]
 </VirtualHost> </VirtualHost>
 <VirtualHost *:443> <VirtualHost *:443>
     DocumentRoot "/var/www/vhosts/repos.tomoyan.net"     DocumentRoot "/var/www/vhosts/repos.tomoyan.net"
     ServerName repos.tomoyan.net     ServerName repos.tomoyan.net
- 
-    SSLEngine on 
-    SSLProtocol all -SSLv2 -SSLv3 
-    SSLCipherSuite !3DES:!aNULL:EDH+HIGH:ECDH+HIGH:-AES128:-3DES:-DSS:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA 
-    SSLHonorCipherOrder on 
     SSLCertificateFile /etc/letsencrypt/live/tomoyan.net/cert.pem     SSLCertificateFile /etc/letsencrypt/live/tomoyan.net/cert.pem
     SSLCertificateKeyFile /etc/letsencrypt/live/tomoyan.net/privkey.pem     SSLCertificateKeyFile /etc/letsencrypt/live/tomoyan.net/privkey.pem
行 238: 行 241:
 </VirtualHost> </VirtualHost>
 </file> </file>
-</WRAP> 
  
 ===== 参考文献 ===== ===== 参考文献 =====
  • linux/httpd/virtualhost_sni_redirect.1550502966.txt.gz
  • 最終更新: 2019/05/18 02:23
  • (外部編集)