awsのロードバランサーを使用しています。
ロードバランサーの設定は以下のようになっています。
HTTP(80) -> HTTP(1080)
HTTPS(443) -> HTTP(80)
接続されているインスタンスが2つあり、そのインスタンス内の/etc/apache2/sites-available/www-prod.conf
は以下のような設定になっています
Listen 1080 <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin www.hoge.com #DocumentRoot /var/www/hoge/sp/dist DocumentRoot /var/www/hoge # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn SetEnvIf User-Agent "ELB-HealthChecker/1\.0" nolog ErrorLog ${APACHE_LOG_DIR}/www-error.log CustomLog ${APACHE_LOG_DIR}/www-access.log custom env=!nolog # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf RewriteEngine on # www=> https(wwwなし) RewriteCond %{HTTP_HOST} ^hoge\.com$ [NC] RewriteRule ^(.*)?$ https://www.hoge.com$1 [R=301,L] # http => https RewriteCond %{HTTP:X-Forwarded-Port} !^443$ RewriteCond %{HTTP_USER_AGENT} !^ELB-HealthChecker RewriteRule ^(.*)?$ https://www.hoge.com$1 [R=301,L] </VirtualHost> <Virtualhost *:1080> ServerName www.hoge.com SetEnvIf User-Agent "ELB-HealthChecker/1\.0" nolog ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log custom env=!nolog RewriteEngine on # www => https(wwwなし) RewriteCond %{HTTP_HOST} ^www.hoge\.com$ [NC] RewriteRule ^(.*)?$ https://hoge.com$1 [R=301,L] # http => https RewriteCond %{HTTP:X-Forwarded-Port} !^443$ RewriteCond %{HTTP_USER_AGENT} !^ELB-HealthChecker RewriteRule ^(.*)?$ https://hoge.com$1 [R=301,L] </Virtualhost>
しかしながら、仮にhttp://hoge.com
にアクセスするとhttps://www.hoge.com
にリダイレクトされてしまいます。どうやら以前の設定が残っているように思えます。sudo service apache2 restart
も実行済みです。
これについて解決法など、教えていただけると大変助かります。OSはUbuntuです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。