Redirect с переменной $host в условии
Alexander Yusupov
kekc at sympatico.ca
Fri Aug 26 21:44:38 MSD 2005
On Friday 26 August 2005 13:29, Igor Sysoev wrote:
> 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"';
www.domain.com 69.156.30.47 - - [26/Aug/2005:13:41:13 -0400] "GET / HTTP/1.1" 200 804 "-" "Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.1 (like Gecko)"
www.domain.com 69.156.30.47 - - [26/Aug/2005:13:41:16 -0400] "GET /style.css HTTP/1.1" 200 527 "http://www.domain.com/" "Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.1 (like Gecko)"
> > 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
--
Regards, Alexander
More information about the nginx-ru
mailing list