質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Q&A

解決済

1回答

1503閲覧

apacheの設定が更新されない

pattern

総合スコア10

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

0グッド

0クリップ

投稿2017/07/09 08:47

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です。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

以下のようになっているのだと思います。

  1. http://hoge.com/ →(ELB)→http://(EC2):1080/
  2. <VirtualHost *:1080> の 2つ目の RewriteRule で https://hoge.com/ にリダイレクト
  3. https://hoge.com/ →(ELB)→http://(EC2):80/
  4. <VirtualHost *:80> の 1つ目の RewriteRule で https://www.hoge.com/ にリダイレクト

投稿2017/07/10 13:18

TaichiYanagiya

総合スコア12146

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問