Google グループ
ヘルプ | ログイン
Modifying vhost with mod_rewrite ?
現在、このグループで最初に表示するトピックが多すぎます。 このトピックを最初に表示するには、別のトピックからこのオプションを削除してください。
リクエストの処理中にエラーが発生しました。 もう一度やり直してください。
フラッグ
  2 件のメッセージ - すべて折りたたんで表示する
投稿先のグループは Usenet グループです。このグループにメッセージを投稿すると、インターネット上のユーザーがメール アドレスを閲覧できるようになります。
返信メッセージが送信されていません。
投稿に成功しました。
 
差出人:
宛先:
Cc:
フォローアップ先:
Cc を追加 | フォローアップ先を追加 | 件名を編集
件名:
確認:
確認のため、下の画像に表示されている文字か、アクセシビリティ アイコンをクリックすると聞こえる数字を入力してください。 聞こえた番号を入力します
 
Brian Atkins  
プロフィールを表示
 詳細オプション 1998年1月1日, 午後5:00
ニュースグループ: comp.infosystems.www.servers.unix
差出人: Brian Atkins <br...@hypermart.net>
日付: 1998/01/01
件名: Modifying vhost with mod_rewrite ?

We are running an experimental server on port 8000 to try and
find a way to map subdomains to our user accounts without using
vhosts. Normally, all users at Hypermart receive a free subdomain
in the form of username.hypermart.net that they can use instead
of the regular www.hypermart.net/username style URL. We can
afford to do that since we are using non-IP vhosts, but we have
over 2500 members now, which has pushed us up close to 3k vhosts
(we also host full domains like www.mycompany.com), which in
turn is causing our httpd processes to be around 6meg in size
each.

Since the subdomains make up the vast number of our vhosts, and
they map perfectly well to our physical dir structure, we are
trying to simply rewrite all URL requests for subdomains
internally using mod_rewrite instead of having vhost entries
for them. Here is our current ruleset:

RewriteEngine on
RewriteCond   %{HTTP_HOST}                 ^www\.hypermart\.net:8000$
RewriteRule   ^(.+)                        - [L]
RewriteCond   %{HTTP_HOST}                 ^[^.]+\.hypermart\.net:8000$
RewriteRule   ^/icons(.+)                  - [PT,L]
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^([^.]+)\.hypermart\.net:8000(.*) /data1/hypermart.net/$1$2

This seems to work great, for instance you can access
http://brian5.hypermart.net:8000 and it works fine. (brian5 is
a test account) However, look at the log entry:

www.hypermart.net 209.86.101.235 - - [01/Jan/1998:15:38:59 -0500] "GET /
HTTP/1.0" 200 1654 "-" "Mozilla/4.04 [en] (Win95; I)"

Notice that the vhost is listed as the main Hypermart site instead
of brian5.hypermart.net. This is critical since we only keep one
log file and split it up nightly. Also, the same problem occurs
when trying to use Frontpage with these "fake" subdomains: it
thinks it is being used on www.hypermart.net instead of brian5
so it barfs. (all users get their own Frontpage vhost so they
can make subwebs)

Is there any way to allow mod_rewrite to modify the internal
vhost that Apache thinks it is using?
--
The future has arrived; it's just not evenly distributed.
                                                       -William Gibson
______________________________________________________________________
Visit Hypermart at http://www.hypermart.net for free business hosting!


    投稿者に返信    転送  
メッセージを投稿するには、ログインする必要があります。
メッセージを投稿するには、まず最初にこのグループに参加する必要があります。
投稿する前に、[設定] ページでニックネームを更新してください。
投稿に必要な権限がありません。
Marc Slemko  
プロフィールを表示
 詳細オプション 1998年1月1日, 午後5:00
ニュースグループ: comp.infosystems.www.servers.unix
差出人: Marc Slemko <ma...@znep.com>
日付: 1998/01/01
件名: Re: Modifying vhost with mod_rewrite ?

In <34AC0117.34546...@hypermart.net> Brian Atkins <br...@hypermart.net> writes:

>We are running an experimental server on port 8000 to try and
>find a way to map subdomains to our user accounts without using
>vhosts. Normally, all users at Hypermart receive a free subdomain
>in the form of username.hypermart.net that they can use instead
>of the regular www.hypermart.net/username style URL. We can
>afford to do that since we are using non-IP vhosts, but we have
>over 2500 members now, which has pushed us up close to 3k vhosts
>(we also host full domains like www.mycompany.com), which in
>turn is causing our httpd processes to be around 6meg in size
>each.

Make sure you have the minimum amount of directives in each
vhost config and be sure you have the minimum number of aliases, etc.
that are not relevant to the vhosts in the main server; they are
inherited by the vhosts.  If you have a lot of stuff in the main
server config that isn't relevant to the vhosts, you may be better
off making the main server a vhost and moving that config into
there.

Note that most of the memory is shared on any decent OS; some, however,
do reserve swap for it all which can be a big pain.

Oh yea, we already went through that in PR#1428.

>Since the subdomains make up the vast number of our vhosts, and
>they map perfectly well to our physical dir structure, we are
>trying to simply rewrite all URL requests for subdomains
>internally using mod_rewrite instead of having vhost entries
>for them. Here is our current ruleset:
>RewriteEngine on
>RewriteCond   %{HTTP_HOST}                 ^www\.hypermart\.net:8000$
>RewriteRule   ^(.+)                        - [L]
>RewriteCond   %{HTTP_HOST}                 ^[^.]+\.hypermart\.net:8000$
>RewriteRule   ^/icons(.+)                  - [PT,L]
>RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
>RewriteRule   ^([^.]+)\.hypermart\.net:8000(.*) /data1/hypermart.net/$1$2

There are a couple of other problems here.  

Most notable, the ServerName means that redirects won't work
properly.  For example, try "http://brian5.hypermart.net:8000/stats"
(without a trailing '/') and you will get a redirect to
"http://www.hypermart.net:8000/stats/" because the ServerName isn't
changed.

This relates back to the logging problem in that Apache doesn't know
that it is rewritten based on some header.

I can't think of any way to do this without changing code.  What you
could do is change the code to have... no, that won't work...
hmm...

Aha.  If you add a line like:

    table_set(e, "HOSTNAME", r->hostname);

to add_common_vars in util_script.c, then you can use "%{HOSTNAME}e"
in a custom log directive to get the proper server name.  You can
use "%{HTTP_HOST}e" or "%{HOST}i" without any source changes, but
that will only get things in the Host: header; if a request with
a hostname comes in (eg.  "GET http://servername/foo/ HTTP/1.0"
instead of

        GET /foo/ HTTP/1.0
        Host: servername

) it will not be logged properly.  The HTTP/1.1 spec says such
requests must not be sent to origin servers but must be accepted,
so it is up to you if you care.  Apache won't accept a request in the
prior form without a Host: header anyway, so it would only matter
if the Host: header is different from the one in the URI (in which
case Apache will prefer the one in the URI), but that's a broken client
so probably not worth the worry.

This still, however, doesn't fix the problem with the hostname
sent for redirects.  It may be possible to fix that via mod_rewrite, but
I don't overly like that solution.

What I am looking at is changing Apache to use r->hostname in
preference to r->server->server_hostname if r->hostname is set.
The problem is that the place where this is done (construct_url)
doesn't get passed r but only r->server.  This would, however, be
fairly easy to hack in but does involve source changes.

This would be a _very_ cool thing to be able to do properly;
especially if you use some domain where you can use wildcard A
records or CNAMES (eg.  *.user.example.com); then you don't even
need to add anything to the DNS to make it work.  I have played
with it a little bit in the past, but not in depth because I have
no use for it.  It certainly does demonstrate a powerful use of
mod_rewrite.  I would be very interested to hear of any issues or
problems that come up if you actually implement this.


    投稿者に返信    転送  
メッセージを投稿するには、ログインする必要があります。
メッセージを投稿するには、まず最初にこのグループに参加する必要があります。
投稿する前に、[設定] ページでニックネームを更新してください。
投稿に必要な権限がありません。
メッセージの終わり
« ディスカッションに戻る « 新しいトピック     過去のトピック »

グループを作成 - Google グループ - Google ホーム - 利用規約 - プライバシー ポリシー
©2009 Google