2017-01-19 17 views
0

Apache Virtual Serverを使用してVPSにWebサイトをホストしました。後でそのVPSでさらにいくつかのサイトをホストする予定です。仮想ホストは、LetsEncrypt Certbotを使用してSSLをインストールするまで、正常に動作していました。その後、https://techkernel.orgは正常に動作しますが、httpバリアントhttp://techkernel.orgはデフォルトのApache Webページにリダイレクトされます。仮想ホストの設定が正しく動作せず、デフォルトの/ var/www/htmlディレクトリに移動しています。Apache仮想ホスト:HTTPがデフォルトのApacheサイトにリダイレクトされる

HTTPとHTTPSの両方の要求がHTTPSにリダイレクトされ、正しいWebサイトが表示されるように修正する方法を教えていただけたら、それは非常に役に立ちます。ありがとうございました。

関連情報:

など/ apache2の/サイト利用可能/ techkernel.org.conf

<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.techkernel.org 

    ServerAdmin [email protected]localhost 
    DocumentRoot "/var/www/techkernel.org/public" 

    ServerAlias techkernel.org 

    # 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 

    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 

    # 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 
    RewriteCond %{SERVER_NAME} =www.techkernel.org [OR] 
    RewriteCond %{SERVER_NAME} =techkernel.org 
    RewriteRule^https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] 

</VirtualHost> 

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet 

VAR/WWW/techkernel.org /公共/ .htaccessの

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{SERVER_NAME}/%$1 [R,L] 

RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 

ls -l/e TC/apache2の/サイト対応

lrwxrwxrwx 1 root root 35 Dec 28 11:08 000-default.conf -> ../sites-available/000-default.conf 
lrwxrwxrwx 1 root root 38 Jan 21 04:31 techkernel.org.conf -> ../sites-available/techkernel.org.conf 
lrwxrwxrwx 1 root root 55 Dec 28 19:46 techkernel.org-le-ssl.conf -> /etc/apache2/sites-available/techkernel.org-le-ssl.conf 

のls -lの/ etc/apache2の/サイト対応

-rw-r--r-- 1 root root 1332 Jul 5 2016 000-default.conf                           
-rw-r--r-- 1 root root 6437 Aug 7 10:56 default-ssl.conf                           
-rw-r--r-- 1 root root 1574 Jan 19 16:05 techkernel.org.conf                           
-rw-r--r-- 1 root root 1613 Dec 28 19:46 techkernel.org-le-ssl.conf 

答えて

0

まあ、000-default.confがうんざりしていることが判明しました。そして、それはapachectl -Sコマンドを実行した後にしか私の通知に来た。修正した後(適切なServerNameDocumentRootといくつかのURL書き換え条件を入力して)、reload ing apache2を実行すると、完全に動作します。

0

あなたはサイト-AVAILABLEからサンプルとしてあなたの設定を貼り付けました。あなたはそれをサイトにシンボリックリンクさせましたか?実際に有効にしました。

編集 - 申し訳ありませんが、それは不必要にうっすらと感じました。私の主張は、HTTPSの亜種が動作しており、別の設定ファイルにあることです。あなたのHTTPはそうではないようですが、このシンボリックリンクを作成していないため、Apacheは「ポート80でリクエストを受け取ったときに、host:headerがtechkernel.orgに設定されているため、デフォルトのサイトに落ちます。そうでなければ、あなたの設定は私にとっては完璧に見えますが、Apacheで実際に使用されていないだけです。

+0

私はこれらの新たなんです。シンボリックリンクを作成するにはどうしたらいいですか? – SkullTech

+0

@SkullTech a2ensite techkernel.org – scampbell

+0

@scampbellそれは動作していないようです。最初に 'Site Techkernel.orgはすでに有効になっている'と述べた。だから私はそれを 'a2dissite''dしてから、もう一度' a2ensite''dします。そして、 'apache2'をリロードしました。しかし、まだ結果はありません。 – SkullTech

0

あなたは多分あなたの000-は、default.confで見つかったエラーのほかに、次のような問題は、あなたの書き換えルールにあった:

RewriteEngine on 
RewriteCond %{SERVER_NAME} =www.techkernel.org [OR] 
RewriteCond %{SERVER_NAME} =techkernel.org 
RewriteRule^https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] 

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www\.)?techkernel.org 
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L] 

%{SERVER_NAME}はからの値可能性があるべきUseCanonicalName Onが設定されている場合、VirtualHost設定。したがって、訪問者が使用しているURIに関係なく、すべてをリダイレクトします。これは意図がある場合には、ただののRewriteCondを削除し、それが固定されている場合は、あなたが/あなたにこのことについてのすべてのエントリを削除する必要があります可能性が

RewriteEngine on 
RewriteRule ^/(.*) https://www.techkernel.org/$1 [NC,R=301,L] 

使用しています。htaccessの

RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{SERVER_NAME}/%$1 [R,L] 
関連する問題