вопрос оффтоп, но интересно

Антон Кирюшкин swood at fotofor.biz
Fri Oct 16 14:14:26 MSD 2009


Хочется сделать автоматические поддомены как в nginx, так и в апач.
Для nginx написан конфиг следующий:

 server {
   listen xxx.xxx.xx.xxx;
   server_name domain.ru *.domain.ru;
   access_log /var/log/nginx/domain-access;
   error_log /var/log/nginx/domain-error error;

   root /var/www/domain/$subdomain;
   set $subdomain "";
   if ($host ~* ^([a-z0-9-\.]+)\.domain.ru$) {
   set $subdomain $1;
   }
   if ($host ~* ^www.domain.ru$) {
   set $subdomain "";
   }

location / {
   proxy_pass                  http://127.0.0.1:8000/;
   index                       index.html index.php;
   proxy_set_header            Host $host;
   proxy_set_header            X-Real-IP $remote_addr;
   proxy_set_header            X-Forwarded-For $remote_addr;
}
}

Для апача такой конфиг:

<VirtualHost 127.0.0.1:8000>
  ServerName domain.ru
  ServerAlias *.domain.ru
 DocumentRoot /var/www/domain
  ErrorLog "/var/log/apache2/domain-error.log"
  CustomLog "/var/log/apache2/domain-access.log" combined

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.domain.ru$
    RewriteCond %{HTTP_HOST} ^((.*).)domain.ru$ [NC]
    RewriteRule ^/(.*) /%2/$1 [L,QSA]
<Directory "/var/www/domain">
    Options FollowSymLinks -MultiViews -Indexes
    AllowOverride All
    Order allow,deny
    Allow from all
</directory>

    RPAFenable On
    RPAFsethostname On
    RPAFproxy_ips 127.0.0.1
    RPAFheader X-Real-IP

</VirtualHost>

Вопрос в том, что если обратиться к subdomain.domain.ru - перекидывает на
domain.ru, если набрать subdomain.domain.ru/index.php - отдаст как надо.
Может быть кто-то знает как это победить..

-- 
Best regards,
Anton Kiryushkin,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20091016/2e41d356/attachment.html>


More information about the nginx-ru mailing list