ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Странная проблема при отсутствии trailing slash в URL



On Tue, Dec 09, 2008 at 06:08:56PM +0200, Alex Umansky wrote:

> Спасибо, Игорь, но это не помогло ;-(
> 
> Директория содержит поддиректории, никаких текстовых файлов.
> Да и это не важно..любая директория с/без пхп файлами внутри идет на бэкенд
> через 301 при отсутствии слэша в конце URL
> 
> proxy_pass срабатывает при / только.

proxy_pass работает, это видно по логу. И там же видно, что именно бэкенд
возращает "Location: http://dynamic.domain.com/data/";
Судя по приведённому конфигу, proxy_pass работать для /data не должен,
так как нет файла /data/php. Стало быть приведена не та конфигурация.

> Тут что-то с этим trailing slash в конце...я ожидал, что nginx сам добавит
> слеш, а в итоге  - бэкенд в адрес баре и 301...

Сначала 301, а лишь потом "бэкенд в адрес баре".

> Спасибо
> 
> 
> 
> 
> 
>  ------------------------------
> 
> On Tue, Dec 09, 2008 at 05:13:39PM +0200, Alex Umansky wrote:
> 
> > В конфиге прописано только прокси для пхп
> >
> > #MAIN LOCATION
> >        location / {
> >        root /var/www/html/;
> >         if (-f $request_filename.php) {
> >         proxy_pass http://dynamic.domain.com;
> >         break;
> >         }
> >        }
> >
> >
> > Кусок лога действительно не тот
> >
> > вот полный ( с запросом на /data)
> >
> > повторюсь, что все работает. Проблема только при реквесте директории без
> > слеша.
> > По идее (так апаче делал), он должен понять файл это или директория. Может
> > модуль какой пропустил?
> 
> Ну вот, видимо, Апач на бэкенде и определяет, что это каталог и
> возращает его со слэшом:
>       Location: http://dynamic.domain.com/data/
> 
> Если нужно, что после nginx'а выходил Location: http://www.domain.com/data/,
> то нужно поставить
> 
>        root  ...
> +      proxy_redirect  http://dynamic.domain.com/  /;
>        if ...
> 
> Непонятно только, почему происходит проксирование.
> Файл /var/www/html/data.php существует ?
> 
> > ./nginx -V
> > nginx version: nginx/0.6.34
> > built by gcc 3.4.6 20060404 (Red Hat 3.4.6-9)
> > configure arguments: --prefix=/usr/local/nginx --user=apache --group=apache
> > --with-http_ssl_module --with-http_realip_module
> > --with-http_gzip_static_module --without-http_fastcgi_module
> > --without-http_empty_gif_module --http-log-path=/var/log/nginx
> > --with-http_stub_status_module --with-debug
> >
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 event timer del: 473: 474497423
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 generic phase: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 generic phase: 1
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location for "/data"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: "/"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: "/"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: "/"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: "/nginx_status"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: ~
> > "/([0-9]+)/([0-1][0-9])/"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: ~
> > "/([0-9]+)/([2-3][0-9])/"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: ~
> > "/([0-9]+)/([4-5][0-9])/"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: ~
> > "/([0-9]+)/([6-7][0-9])/"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: ~
> > "/([0-9]+)/([8-9][0-9])/"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: ~
> > "^.+\.(jpg|jpeg|gif)$"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: ~
> > "^.+\.(html|js|css)$"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 find location: ~ "\.xml$"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 using configuration "/"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http cl:-1 max:0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 generic phase: 3
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 post rewrite phase: 4
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 generic phase: 5
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 generic phase: 6
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 access phase: 7
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 access phase: 8
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 post access phase: 9
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http init upstream, client
> > timer: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 epoll add event: fd:473 op:3
> > ev:80000005
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script copy: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script var: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script copy: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script copy: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script var: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script copy: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script copy: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script var: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script copy: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script copy: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script var: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script copy: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http script copy: ""
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header: "Accept:
> > image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
> > application/x-shockwave-flash, application/vnd.ms-excel,
> > application/vnd.ms-powerpoint, application/msword, application/xaml+xml,
> > application/vnd.ms-xpsdocument, application/x-ms-xbap,
> > application/x-ms-application, application/x-silverlight, */*"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header:
> > "Accept-Language: en-us,he;q=0.5"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header:
> > "Accept-Encoding: gzip, deflate"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header: "User-Agent:
> > Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB5; .NET CLR
> > 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648;
> > FDM)"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header: "Cookie:
> > xxx"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header:
> > "GET /data HTTP/1.0
> > X-Forwarded-For:  xxx.xxx.xxx.xxx
> > X-Forwarded-Host: www.domain.com
> > Host: dynamic.domain.com
> > X-Forwarded-Server: www.domain.com
> > Connection: close
> > Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
> > application/x-shockwave-flash, application/vnd.ms-excel,
> > application/vnd.ms-powerpoint, application/msword, application/xaml+xml,
> > application/vnd.ms-xpsdocument, application/x-ms-xbap,
> > application/x-ms-application, application/x-silverlight, */*
> > Accept-Language: en-us,he;q=0.5
> > Accept-Encoding: gzip, deflate
> > User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB5;
> > .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR
> > 3.0.04506.648; FDM)
> > Cookie: xxx"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http cleanup add: 09B373F8
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 get rr peer, try: 1
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 socket 543
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 epoll add connection: fd:543
> > ev:80000005
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 connect to 10.232.22.170:80,
> > fd:543 #914137
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream connect: -2
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 event timer add: 543:
> > 90000:474407435
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 post event B79CD6B8
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 delete posted event B79CD6B8
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream check client,
> > write event:1, "/data"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream recv(): -1 (11:
> > Resource temporarily unavailable)
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 post event B79CE454
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 delete posted event B79CE454
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream send request
> > handler
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream send request
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 chain writer buf fl:1 s:1038
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 chain writer in: 09B37414
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 writev: 1038
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 chain writer out: 00000000
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 event timer del: 543: 474407435
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 event timer add: 543:
> > 90000:474407438
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 post event B7B6B454
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 post event B79CE454
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 delete posted event B79CE454
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream dummy handler
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 delete posted event B7B6B454
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream process header
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 malloc: 09C2FB20:4096
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 recv: fd:543 516 of 4096
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy status 301 "301
> > Moved Permanently"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header: "Date: Tue,
> > 09 Dec 2008 15:02:08 GMT"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header: "Server:
> > Apache"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header: "Location:
> > http://dynamic.domain.com/data/";;
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header:
> > "Content-Length: 303"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header: "Connection:
> > close"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header:
> > "Content-Type: text/html; charset=iso-8859-1"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http proxy header done
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 HTTP/1.1 301 Moved Permanently
> > Server: nginx/0.6.34
> > Date: Tue, 09 Dec 2008 15:02:44 GMT
> > Content-Type: text/html; charset=iso-8859-1
> > Connection: keep-alive
> > Keep-Alive: timeout=30
> > Location: http://dynamic.domain.com/data/
> > Content-Length: 303
> >
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 write new buf t:1 f:0 09B3760C,
> > pos 09B3760C, size: 248 file: 0, size: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http write filter: l:0 f:0
> > s:248
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream process upstream
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 pipe read upstream: 1
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 pipe preread: 303
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 readv: 1:3580
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 pipe recv chain: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 pipe buf free s:0 t:1 f:0
> > 09C2FB20, pos 09C2FBF5, size: 303 file: 0, size: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 input buf #0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 pipe write downstream: 1
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 pipe write downstream flush in
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http output filter "/data?"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 copy filter: "/data?"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 malloc: 09CE9158:4096
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http postpone filter "/data?"
> > 09B377F4
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http postpone filter out
> > "/data?"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 write old buf t:1 f:0 09B3760C,
> > pos 09B3760C, size: 248 file: 0, size: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 write new buf t:1 f:0 09C2FB20,
> > pos 09C2FBF5, size: 303 file: 0, size: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http write filter: l:0 f:0
> > s:551
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 copy filter: 0 "/data?"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 pipe write downstream done
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 event timer: 543, old:
> > 474407438, new: 474407439
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream exit: 00000000
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 finalize http upstream request:
> > 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 finalize http proxy request
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 free rr peer 1 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 close http upstream connection:
> > 543
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 event timer del: 543: 474407438
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http upstream temp fd: -1
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http output filter "/data?"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 copy filter: "/data?"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http postpone filter "/data?"
> > BFEED108
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http postpone filter out
> > "/data?"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 write old buf t:1 f:0 09B3760C,
> > pos 09B3760C, size: 248 file: 0, size: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 write old buf t:1 f:0 09C2FB20,
> > pos 09C2FBF5, size: 303 file: 0, size: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 write new buf t:0 f:0 00000000,
> > pos 00000000, size: 0 file: 0, size: 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http write filter: l:1 f:0
> > s:551
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http write filter limit 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 writev: 551
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http write filter 00000000
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 copy filter: 0 "/data?"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http finalize request: 0,
> > "/data?"
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 set http keepalive handler
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http close request
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http log handler
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 free: 09C2FB20
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 free: 09B36800, unused: 4
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 free: 09CE9158, unused: 3683
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 event timer add: 473:
> > 30000:474347439
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 free: 09AC0710
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 free: 099B8E50
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 hc free: 00000000 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 hc busy: 00000000 0
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 tcp_nodelay
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 post event B7B6A6B8
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 delete posted event B7B6A6B8
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 http keepalive handler
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 malloc: 099B8E50:1024
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 recv: fd:473 -1 of 1024
> > 2008/12/09 10:02:44 [debug] 22188#0: *914133 recv() not ready (11: Resource
> > temporarily unavailable)
> >
> >
> >
> >
> >  Спасибо!
> 
> -- 
> Игорь Сысоевhttp://sysoev.ru

-- 
Игорь Сысоев
http://sysoev.ru



 




Copyright © Lexa Software, 1996-2009.