Redirect с переменной $host в условии
Igor Sysoev
is at rambler-co.ru
Fri Aug 26 21:29:58 MSD 2005
On Fri, 26 Aug 2005, Alexander Yusupov wrote:
>>> Плюс к этому игнорируется директива:
>>> location ~* ^.+\.(swf|GIF|gif|JPG|JPEG|jpg|jpeg|PNG|png|ICO|ico|js|css)$
>>> { access_log off;
>>> expires 30d;
>>> }
>>
>> Не нужно указывать "GIF|gif", поскольку для "~*" достаточно одного
>> варианта - "gif".
>>
>> Что значит - игнорируется ? Под каким location обрабатываются запросы,
>> котороые должны обрабатываться в этом ?
> т.е. в лог пишется все, включая картики и css, например делаю запрос
> www.domen.com в лог получаю:
> www.domen.com
> www.domen.com/style.css
А можно привести всю строку в описанном формате
log_format vhost '%{Host}i %addr - - [%time] "%request" %status %length
"%{Referer}i" "%{User-Agent}i"';
> location ~* ^.+\.(swf|gif|jpg|jpeg|png|ico|js|css)$ {
> #root /www/catalog/www;
> access_log off;
> expires 30d;
> }
>
> в чем может быть проблема?
>
>>> nginx.conf
>>> ----------------------
>>> user www;
>>> worker_processes 15;
>>>
>>> error_log /var/log/nginx/error.log;
>>> pid /var/run/nginx.pid;
>>>
>>>
>>> events {
>>> connections 1024;
>>> use kqueue;
>>> }
>>>
>>>
>>> http {
>>> include mime.types;
>>> default_type text/plain;
>>>
>>> sendfile on;
>>> tcp_nopush on;
>>> tcp_nodelay on;
>>>
>>>
>>> keepalive_timeout 75 20;
>>>
>>> gzip on;
>>> gzip_min_length 1100;
>>> gzip_types text/plain;
>>>
>>> log_format vhost '%{Host}i %addr - - [%time] "%request" %status %length
>>> "%{Referer}i" "%{User-Agent}i"';
>>>
>>> server {
>>>
>>> listen 80;
>>> server_name somename.com;
>>>
>>>
>>> root /www/catalog/www;
>>>
>>> location ~*
>>> ^.+\.(swf|GIF|gif|JPG|JPEG|jpg|jpeg|PNG|png|ICO|ico|js|css)$ { root
>>> /www/catalog/www;
>>> access_log off;
>>> expires 30d;
>>> }
>>>
>>>
>>> access_log /var/log/nginx/access.log vhost;
>>>
>>>
>>> location / {
>>> root /www/catalog/www;
>>> index index.php;
>>> }
>>>
>>> error_page 404 /;
>>>
>>> # deny access to .htaccess files
>>> location ~ /\.ht {
>>> deny all;
>>> }
>>>
>>> # location /status { stub_status on; }
>>>
>>>
>>>
>>> location ~* ^.+\.php$ {
>>> root /www/catalog/www;
>>>
>>> fastcgi_pass 127.0.0.1:1088;
>>> fastcgi_index index.php;
>>>
>>> fastcgi_param SCRIPT_FILENAME /www/catalog/www$fastcgi_script_name;
>>> fastcgi_param QUERY_STRING $query_string;
>>> fastcgi_param REQUEST_METHOD $request_method;
>>> fastcgi_param CONTENT_TYPE $content_type;
>>> fastcgi_param CONTENT_LENGTH $content_length;
>>>
>>> # жрет ресурсы, без нужды не использоват
>>> fastcgi_param REMOTE_ADDR $remote_addr;
>>> fastcgi_param SERVER_PORT $server_port;
>>> fastcgi_param REDIRECT_STATUS 200;
>>>
>>> fastcgi_param DOCUMENT_ROOT /www/catalog/www;
>>> fastcgi_param SCRIPT_FILENAME /www/catalog/www$fastcgi_script_name;
>>> fastcgi_param PATH_TRANSLATED /www/catalog/www$fastcgi_script_name;
>>> fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>>>
>>> fastcgi_param QUERY_STRING $query_string;
>>> fastcgi_param CONTENT_TYPE $content_type;
>>> fastcgi_param CONTENT_LENGTH $content_length;
>>> fastcgi_param REDIRECT_STATUS 200;
>>> #additional system call is made, without need it is better to not use
>>> fastcgi_param SERVER_ADDR $server_addr;
>>> fastcgi_param SERVER_PORT $server_port;
>>> fastcgi_param SERVER_PROTOCOL $server_protocol;
>>> fastcgi_param SERVER_SOFTWARE "nginx";
>>> fastcgi_param GATEWAY_INTERFACE "CGI/1.1";
>>> fastcgi_param SERVER_NAME $server_name;
>>> fastcgi_param REQUEST_URI $request_uri;
>>> fastcgi_param REQUEST_METHOD $request_method;
>>> fastcgi_param REMOTE_USER $remote_user;
>>> fastcgi_param REMOTE_ADDR $remote_addr;
>>> fastcgi_param REMOTE_PORT $remote_port;
>>>
>>>
>>> }
>>>
>>>
>>> if ($http_host ~ !^www\. ){
>>> rewrite ^(.*)$ http://www.$http_host$1;
>>> }
>>>
>>>
>>> }
>>>
>>>
>>> }
Игорь Сысоев
http://sysoev.ru
More information about the nginx-ru
mailing list