Apacheのリバースプロキシ機能(Debian Etch)を使用してポート80でISPConfig2を実行する
この記事では、ウェブホスティングコントロールパネルISPConfig2がインストールされているDebianEtchシステムを構成して、ポート80でISPConfigにアクセスできるようにする方法を示します。デフォルトでは、ISPConfigは非標準ポートであるポート81を使用し、一部のファイアウォールとISP。 Apacheのmod_proxyモジュールを使用することで、この問題を回避できます。これにより、ポート81でISPConfigからページをフェッチできるリバースプロキシを作成できます。
注:このチュートリアルはISPConfig 2のみを対象としており、ISPConfig3とは互換性がありません。ISPConfig3の場合、githubでNginxリバースプラグインを利用できます。
これがあなたのために働くという保証はありません!
1予備メモ
私はこれをDebianEtchシステムでテストしました。このチュートリアルの一部のコマンドはDebian固有ですが、そのほとんどは他のLinuxディストリビューション(特にApache構成)に適用できます。
このチュートリアルでは、ホスト名ispconfig.example.comを使用しています。このチュートリアルの目的は、URLhttp://ispconfig.example.comでISPConfigにアクセスすることです。これを行う方法を2つの別々の章で示します。1つはISPConfigがhttp://ispconfig.example.com:81(http)にインストールされている場合、もう1つはISPConfigがhttps://ispconfigにインストールされている場合です。 .example.com:81(https)。
2 ISPConfig Using http(http://ispconfig.example.com:81)
httpリクエストのリバースプロキシを作成するには、Apacheモジュールのmod_proxyとmod_proxy_httpが必要です。これらはすでに標準のDebianEtchApache 2.2インストールにインストールされているので、私たちがしなければならないのはそれらを有効にすることだけです:
a2enmod proxy
a2enmod proxy_http
その後、Apacheをリロードする必要があります:
/etc/init.d/apache2 force-reload
次に、Apacheを構成する必要があります。 /etc/apache2/apache2.confを開き、次のセクションを検索します:
vi /etc/apache2/apache2.conf
[...] # Include the virtual host configurations: Include /etc/apache2/sites-enabled/ <Directory /var/www/sharedip> Options +Includes -Indexes AllowOverride None AllowOverride Indexes AuthConfig Limit FileInfo Order allow,deny Allow from all <Files ~ "^\.ht"> Deny from all </Files> </Directory> [...] |
このセクションの直前に、次の行を追加します。
NameVirtualHost * <VirtualHost *> ServerName ispconfig.example.com DocumentRoot /var/www/ ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://ispconfig.example.com:81/ ProxyPassReverse / http://ispconfig.example.com:81/ </VirtualHost> |
次のようになります:
[...] NameVirtualHost * <VirtualHost *> ServerName ispconfig.example.com DocumentRoot /var/www/ ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://ispconfig.example.com:81/ ProxyPassReverse / http://ispconfig.example.com:81/ </VirtualHost> # Include the virtual host configurations: Include /etc/apache2/sites-enabled/ <Directory /var/www/sharedip> Options +Includes -Indexes AllowOverride None AllowOverride Indexes AuthConfig Limit FileInfo Order allow,deny Allow from all <Files ~ "^\.ht"> Deny from all </Files> </Directory> [...] |
次に、Apacheを再起動します:
/etc/init.d/apache2 restart
このような警告が表示された場合:
server1:~/ispconfig/httpd/conf# /etc/init.d/apache2 restart
Forcing reload of web server (apache2)...[Tue May 22 23:23:12 2007] [warn] NameVirtualHost *:0 has no VirtualHosts
[Tue May 22 23:23:22 2007] [warn] NameVirtualHost *:0 has no VirtualHosts
次に、「Include / etc / apache2 / sites-enabled / in /etc/apache2/apache2.conf:
」の行をコメントアウトできます。vi /etc/apache2/apache2.conf
[...] # Include the virtual host configurations: #Include /etc/apache2/sites-enabled/ [...]> |
または、/ etc / apache2 / sites-available /defaultの先頭にあるNameVirtualHost*の行をコメントアウトします:
vi /etc/apache2/sites-available/default
#NameVirtualHost * [...] |
Apacheを再起動します:
/etc/init.d/apache2 restart
警告は今すぐ消えるはずです。
最後に、ISPConfig構成ファイル/home/admispconfig/ispconfig/lib/config.inc.phpを変更する必要があります。その中に次のようなものが見つかるはずです:
vi /home/admispconfig/ispconfig/lib/config.inc.php
[...] if(isset($_SERVER['HTTP_HOST'])){ $go_info["server"]["server_url"] = 'http://'.$_SERVER['HTTP_HOST']; } else { $go_info["server"]["server_url"] = "http://ispconfig.example.com:81"; } [...] |
次のように変更します:
[...] //if(isset($_SERVER['HTTP_HOST'])){ // $go_info["server"]["server_url"] = 'http://'.$_SERVER['HTTP_HOST']; //} else { $go_info["server"]["server_url"] = "http://ispconfig.example.com"; //} [...] |
それでおしまい。ブラウザを開いてhttp://ispconfig.example.comと入力すると、ISPConfigログインプロンプトが表示されます。
3 ISPConfig Using https(https://ispconfig.example.com:81)
httpリクエストのリバースプロキシを作成するには、Apacheモジュールのmod_proxyとmod_proxy_httpが必要です。これらはすでに標準のDebianEtchApache 2.2インストールにインストールされているので、私たちがしなければならないのはそれらを有効にすることだけです:
a2enmod proxy
a2enmod proxy_http
Apacheリバースプロキシはhttpsサイト(https://ispconfig.example.com:81)と「通信」できる必要があるため、モジュールmod_proxy_connectおよびmod_ssl:
も必要です。a2enmod proxy_connect
a2enmod ssl
その後、Apacheをリロードする必要があります:
/etc/init.d/apache2 force-reload
次に、Apacheを構成する必要があります。 /etc/apache2/apache2.confを開き、次のセクションを検索します:
vi /etc/apache2/apache2.conf
[...] # Include the virtual host configurations: Include /etc/apache2/sites-enabled/ <Directory /var/www/sharedip> Options +Includes -Indexes AllowOverride None AllowOverride Indexes AuthConfig Limit FileInfo Order allow,deny Allow from all <Files ~ "^\.ht"> Deny from all </Files> </Directory> [...] |
このセクションの直前に、次の行を追加します。
NameVirtualHost * <VirtualHost *> ServerName ispconfig.example.com DocumentRoot /var/www/ ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / https://ispconfig.example.com:81/ ProxyPassReverse / https://ispconfig.example.com:81/ SSLProxyEngine on AllowCONNECT 81 </VirtualHost> |
次のようになります:
[...] NameVirtualHost * <VirtualHost *> ServerName ispconfig.example.com DocumentRoot /var/www/ ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / https://ispconfig.example.com:81/ ProxyPassReverse / https://ispconfig.example.com:81/ SSLProxyEngine on AllowCONNECT 81 </VirtualHost> # Include the virtual host configurations: Include /etc/apache2/sites-enabled/ <Directory /var/www/sharedip> Options +Includes -Indexes AllowOverride None AllowOverride Indexes AuthConfig Limit FileInfo Order allow,deny Allow from all <Files ~ "^\.ht"> Deny from all </Files> </Directory> [...]から拒否する |
次に、Apacheを再起動します:
/etc/init.d/apache2 restart
このような警告が表示された場合:
server1:~/ispconfig/httpd/conf# /etc/init.d/apache2 restart
Forcing reload of web server (apache2)...[Tue May 22 23:23:12 2007] [warn] NameVirtualHost *:0 has no VirtualHosts
[Tue May 22 23:23:22 2007] [warn] NameVirtualHost *:0 has no VirtualHosts
次に、「Include / etc / apache2 / sites-enabled / in /etc/apache2/apache2.conf:
」の行をコメントアウトできます。vi /etc/apache2/apache2.conf
[...] # Include the virtual host configurations: #Include /etc/apache2/sites-enabled/ [...]> |
または、/ etc / apache2 / sites-available /defaultの先頭にあるNameVirtualHost*の行をコメントアウトします:
vi /etc/apache2/sites-available/default
#NameVirtualHost * [...] |
Apacheを再起動します:
/etc/init.d/apache2 restart
警告は今すぐ消えるはずです。
最後に、ISPConfig構成ファイル/home/admispconfig/ispconfig/lib/config.inc.phpを変更する必要があります。その中に次のようなものが見つかるはずです:
vi /home/admispconfig/ispconfig/lib/config.inc.php
[...] if(isset($_SERVER['HTTP_HOST'])){ $go_info["server"]["server_url"] = 'https://'.$_SERVER['HTTP_HOST']; } else { $go_info["server"]["server_url"] = "https://ispconfig.example.com:81"; } [...] |
次のように変更します:
[...] //if(isset($_SERVER['HTTP_HOST'])){ // $go_info["server"]["server_url"] = 'https://'.$_SERVER['HTTP_HOST']; //} else { $go_info["server"]["server_url"] = "http://ispconfig.example.com"; //} [...] |
https://ispconfig.example.comではなくhttp://ispconfig.example.comと表示されていることを確認してください!
それでおしまい。ブラウザを開いてhttp://ispconfig.example.comと入力すると、ISPConfigログインプロンプトが表示されます。
4つのリンク
- Apacheモジュールmod_proxy:http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
- Apache:http://httpd.apache.org
- ISPConfig:http://www.ispconfig.org
- Debian:http://www.debian.org