2015-03-10 2 views
0

Я настроил диспетчера на своем локальном сервере AEM и теперь попробовал URL http://www.mywebapp.com (эта запись также сделана в файле hosts). Вот ошибка, которую я получаюAEM :: Dispatcher issue

[Tue Mar 10 12:25:43 2015] [D] [7268(496)] Found farm website for www.mywebapp.com 
[Tue Mar 10 12:25:43 2015] [D] [7268(496)] checking [/] 
[Tue Mar 10 12:25:43 2015] [D] [7268(496)] request URL has no extension:/
[Tue Mar 10 12:25:43 2015] [D] [7268(496)] cache-action for [/]: NONE 
[Tue Mar 10 12:25:43 2015] [D] [7268(496)] Filter rejects: GET/HTTP/1.1 
[Tue Mar 10 12:25:43 2015] [I] [7268(496)] "GET /" - - 1ms 

Это файл dispatcher.any. Я не уверен, что фильтр точно блокирует запрос:

# Each farm configures a set of load balanced renders (i.e. remote servers) 
/farms 
    { 
    # First farm entry 
    /website 
    { 
    # Request headers that should be forwarded to the remote server. 
    /clientheaders 
     { 
     # Forward all request headers that are end-to-end. If you want 
     # to forward a specific set of headers, you'll have to list 
     # them here. 
     "*" 
     } 

    # Hostname globbing for farm selection (virtual domain addressing) 
    /virtualhosts 
     { 
     # Entries will be compared against the "Host" request header 
     # and an optional request URL prefix. 
     # 
     # Examples: 
     # 
     # www.company.com 
     # intranet.* 
     # myhost:8888/mysite 
     "*" 
     } 

    # The load will be balanced among these render instances 
    /renders 
     { 
     /rend01 
     { 
     # Hostname or IP of the render 
     /hostname "127.0.0.1" 
     # Port of the render 
     /port "4503" 
     # Connect timeout in milliseconds, 0 to wait indefinitely 
     # /timeout "0" 
     } 
     } 

    # The filter section defines the requests that should be handled by the dispatcher. 
    # The globs will be compared against the request line, e.g. "GET /index.html HTTP/1.1". 
    /filter 
     { 
     # Deny everything first and then allow specific entries 
     /0001 { /type "deny" /glob "*" } 

     # Open consoles 
#  /0011 { /type "allow" /glob "* /admin/*" } # allow servlet engine admin 
#  /0012 { /type "allow" /glob "* /crx/*" } # allow content repository 
#  /0013 { /type "allow" /glob "* /system/*" } # allow OSGi console 

     # Allow non-public content directories 
#  /0021 { /type "allow" /glob "* /apps/*" } # allow apps access 
#  /0022 { /type "allow" /glob "* /bin/*" } 
     /0023 { /type "allow" /glob "* /content*" } # disable this rule to allow mapped content only 

#  /0024 { /type "allow" /glob "* /libs/*" } 
#  /0025 { /type "deny" /glob "* /libs/shindig/proxy*" } # if you enable /libs close access to proxy 

#  /0026 { /type "allow" /glob "* /home/*" } 
#  /0027 { /type "allow" /glob "* /tmp/*" } 
#  /0028 { /type "allow" /glob "* /var/*" } 

     # Enable specific mime types in non-public content directories 
     /0041 { /type "allow" /glob "* *.css *" } # enable css 
     /0042 { /type "allow" /glob "* *.gif *" } # enable gifs 
     /0043 { /type "allow" /glob "* *.ico *" } # enable icos 
     /0044 { /type "allow" /glob "* *.js *" } # enable javascript 
     /0045 { /type "allow" /glob "* *.png *" } # enable png 
     /0046 { /type "allow" /glob "* *.swf *" } # enable flash 
     /0047 { /type "allow" /glob "* *.html *" } # enable flash 

     # Enable features 
     /0061 { /type "allow" /glob "POST /content/[.]*.form.html" } # allow POSTs to form selectors under content 
     /0062 { /type "allow" /glob "* /libs/cq/personalization/*" } # enable personalization 

     # Deny content grabbing 
     /0081 { /type "deny" /glob "GET *.infinity.json*" } 
     /0082 { /type "deny" /glob "GET *.tidy.json*"  } 
     /0083 { /type "deny" /glob "GET *.sysview.xml*" } 
     /0084 { /type "deny" /glob "GET *.docview.json*" } 
     /0085 { /type "deny" /glob "GET *.docview.xml*" } 

     /0086 { /type "deny" /glob "GET *.*[0-9].json*" } 
#  /0087 { /type "allow" /glob "GET *.1.json*" }   # allow one-level json requests 

     # Deny query 
     /0090 { /type "deny" /glob "* *.query.json*" } 
     } 

    # The cache section regulates what responses will be cached and where. 
    /cache 
     { 
     # The docroot must be equal to the document root of the webserver. The 
     # dispatcher will store files relative to this directory and subsequent 
     # requests may be "declined" by the dispatcher, allowing the webserver 
     # to deliver them just like static files. 
     /docroot "C:/Apache2.2/htdocs" 

     # Sets the level upto which files named ".stat" will be created in the 
     # document root of the webserver. When an activation request for some 
     # page is received, only files within the same subtree are affected 
     # by the invalidation. 
     /statfileslevel "3" 

     # Flag indicating whether to cache responses to requests that contain 
     # authorization information. 
     /allowAuthorized "1" 

     # Flag indicating whether the dispatcher should serve stale content if 
     # no remote server is available. 
     #/serveStaleOnError "0" 

     # The rules section defines what responses should be cached based on 
     # the requested URL. Please note that only the following requests can 
     # lead to cacheable responses: 
     # 
     # - HTTP method is GET 
     # - URL has an extension 
     # - Request has no query string 
     # - Request has no "Authorization" header (unless allowAuthorized is 1) 
     /rules 
     { 
     /0000 
      { 
      # the globbing pattern to be compared against the url 
      # example: *    -> everything 
      #  : /foo/bar.* -> only the /foo/bar documents 
      #  : /foo/bar/* -> all pages below /foo/bar 
      #  : /foo/bar[./]* -> all pages below and /foo/bar itself 
      #  : *.html  -> all .html files 
      /glob "*" 
      /type "allow" 
      } 
     } 

     # The invalidate section defines the pages that are "invalidated" after 
     # any activation. Please note that the activated page itself and all 
     # related documents are flushed on an modification. For example: if the 
     # page /foo/bar is activated, all /foo/bar.* files are removed from the 
     # cache. 
     /invalidate 
     { 
     /0000 
      { 
      /glob "*" 
      /type "deny" 
      } 
     /0001 
      { 
      # Consider all HTML files stale after an activation. 
      /glob "*.html" 
      /type "allow" 
      } 
     } 

     # The allowedClients section restricts the client IP addresses that are 
     # allowed to issue activation requests. 
     /allowedClients 
     { 
     # Uncomment the following to restrict activation requests to originate 
     # from "localhost" only. 
     # 
     #/0000 
     # { 
     # /glob "*" 
     # /type "deny" 
     # } 
     #/0001 
     # { 
     # /glob "127.0.0.1" 
     # /type "allow" 
     # } 
     } 
     } 

    # The statistics sections dictates how the load should be balanced among the 
    # renders according to the media-type. 
    /statistics 
     { 
     /categories 
     { 
     /html 
      { 
      /glob "*.html" 
      } 
     /others 
      { 
      /glob "*" 
      } 
     } 
     } 
    } 
    } 
+0

не уверен в ошибке, но первое правило фильтра блокирует все, а более поздние правила допускают некоторые исключения:/0001 {/ type "deny"/glob "*"} – Thomas

+0

Спасибо за ответ. Я знаю, что работает фильтр диспетчера. Я не могу понять, какое правило блокирует GET/ – user972418

+0

. Я имел в виду, что правило, о котором я упоминал, блокирует ваш GET/ – Thomas

ответ

3

вы должны иметь mod_rewrite Перенаправление «GET /» запрос на «GET /content/mywebapp/en.html» (среди других правил). «GET /» нельзя кэшировать, потому что у него нет расширения, и вы, вероятно, хотите, чтобы ваша домашняя страница была кэширована.

0

Вот пример, который мы сделали для одного из Taining сайтов

# first farm entry (label is not important, just for your convenience) 
 
    /cookbook 
 
    { 
 
    # client headers which should be passed through to the render instances 
 
    # (feature supported since dispatcher build 2.6.3.5222) 
 
    /clientheaders 
 
     { 
 
     "referer" 
 
     "user-agent" 
 
     "authorization" 
 
     "from" 
 
     "content-type" 
 
     "content-length" 
 
     "accept-charset" 
 
     "accept-encoding" 
 
     "accept-language" 
 
     "accept" 
 
     "host" 
 
     "if-match" 
 
     "if-none-match" 
 
     "if-range" 
 
     "if-unmodified-since" 
 
     "max-forwards" 
 
     "proxy-authorization" 
 
     "proxy-connection" 
 
     "range" 
 
     "cookie" 
 
     "cq-action" 
 
     "cq-handle" 
 
     "handle" 
 
     "action" 
 
     "cqstats" 
 
     "depth" 
 
     "translate" 
 
     "expires" 
 
     "date" 
 
     "dav" 
 
     "ms-author-via" 
 
     "if" 
 
     "lock-token" 
 
     "x-expected-entity-length" 
 
     "destination" 
 
     } 
 
    # hostname globbing for farm selection (virtual domain addressing) 
 
    /virtualhosts 
 
     { 
 
     # entries will be compared against the 'host' request header. 
 
     # example: www.company.com 
 
     # example: intranet.* 
 
     "*" 
 
     } 
 
    # the load will be balanced among these render instances 
 
    /renders 
 
     { 
 
     /publish1 
 
     { 
 
     # hostname or IP of the render 
 
     /hostname "localhost" 
 
     # port of the render 
 
     /port "4503" 
 
     # connect timeout in milliseconds, 0 to wait indefinitely 
 
     /timeout "0" 
 
     } 
 
     } 
 
    # only handle the requests in the following acl. default is 'none' 
 
    # the glob pattern is matched against the first request line 
 
    /filter 
 
     { 
 
     # deny everything and allow specific entries 
 
     /0001 { /type "deny" /glob "*" } 
 

 
     # open consoles 
 
# /0012 { /type "allow" /glob "* /crx/*" } # allow content repository 
 
# /0013 { /type "allow" /glob "* /system/*" } # allow OSGi console 
 

 
     # allow non-public content directories 
 
# /0021 { /type "allow" /glob "* /apps/*" } # allow apps access 
 
     /0022 { /type "allow" /glob "* /bin/*" } 
 
     /0023 { /type "allow" /glob "* /content*" } # disable this rule to allow mapped content only 
 

 
# /0024 { /type "allow" /glob "* /libs/*" } 
 
# /0025 { /type "deny" /glob "* /libs/shindig/proxy*" } # if you enable /libs close access to proxy 
 

 
# /0026 { /type "allow" /glob "* /home/*" } 
 
# /0027 { /type "allow" /glob "* /tmp/*" } 
 
# /0028 { /type "allow" /glob "* /var/*" } 
 

 
     # enable specific mime types in non-public content directories 
 
     /0041 { /type "allow" /glob "* *.css *" } # enable css 
 
     /0042 { /type "allow" /glob "* *.gif *" } # enable gifs 
 
     /0043 { /type "allow" /glob "* *.ico *" } # enable icos 
 
     /0044 { /type "allow" /glob "* *.js *" } # enable javascript 
 
     /0045 { /type "allow" /glob "* *.png *" } # enable png 
 
     /0046 { /type "allow" /glob "* *.swf *" } # enable flash 
 
     /0047 { /type "allow" /glob "* *.svg *" } # enable SVG 
 
     /0048 { /type "allow" /glob "* *.woff *" } # enable woff 
 
     /0049 { /type "allow" /glob "* *.ttf *" } # enable ttf 
 
     /0050 { /type "allow" /glob "* *.eot *" } # enable eot 
 
     /0051 { /type "allow" /glob "* *.jpg *" } # enable jpg 
 

 
     /0052 { /type "allow" /glob "* /services/*" } # enable servlet services 
 

 
     # enable features 
 
     /0061 { /type "allow" /glob "POST /content/[.]*.form.html" } # allow POSTs to form selectors under content 
 
     /0062 { /type "allow" /glob "* /libs/cq/personalization/*" } # enable personalization 
 

 
     # deny content grabbing 
 
     /0081 { /type "deny" /glob "GET *.infinity.json*" } 
 
     /0082 { /type "deny" /glob "GET *.tidy.json*"  } 
 
     /0083 { /type "deny" /glob "GET *.sysview.xml*" } 
 
     /0084 { /type "deny" /glob "GET *.docview.json*" } 
 
     /0085 { /type "deny" /glob "GET *.docview.xml*" } 
 
     /0086 { /type "deny" /glob "GET *.*[0-9].json*" } 
 
     /0087 { /type "deny" /glob "GET *.feed.xml*"  } 
 
# /0088 { /type "allow" /glob "GET *.1.json*"  } # allow one-level json requests 
 
     /0089 { /type "allow" /glob "GET /etc/clientcontext/.*/*.json*.*" } 
 

 
     # deny query 
 
     /0090 { /type "deny" /glob "* *.query.json*" } 
 
     } 
 

 
    # allow propagation of replication posts (should seldomly be used) 
 
    /propagateSyndPost "0" 
 

 
    # the cache is used to store requests from the renders for faster delivery 
 
    # for a second time. 
 
    /cache 
 
     { 
 
     # the cacheroot must be equal to the document root of the webserver 
 
     /docroot "/var/www/html/content/cookbook" 
 

 
     # sets the level upto which files named ".stat" will be created in the 
 
     # document root of the webserver. when an activation request for some 
 
     # handle is received, only files within the same subtree are affected 
 
     # by the invalidation. 
 
     /statfileslevel "0" 
 
     # caches also authorized data 
 
     /allowAuthorized "1" 
 

 
     # the rules define, which pages should be cached. please note that 
 
     # - only GET requests are cached 
 
     # - only requests with an extension are cached 
 
     # - only requests without query parameters (?) are cached 
 
     # - only unauthorized pages are cached unless allowUnauthorized is set to 1 
 
     /rules 
 
     { 
 
     /0000 
 
      { 
 
      # the globbing pattern to be compared against the url 
 
      # example: *  -> everything 
 
      #  : /foo/bar.* -> only the /foo/bar documents 
 
      #  : /foo/bar/* -> all pages below /foo/bar 
 
      #  : /foo/bar[./]* -> all pages below and /foo/bar itself 
 
      #  : *.html  -> all .html files 
 
      /glob "*" 
 
      /type "allow" 
 
      } 
 
     } 
 
     # the invalidate section defines those pages which are 'invalidated' after 
 
     # any activation. please note that, the activated page itself and all 
 
     # related documents are flushed on an modification. for example: if the 
 
     # page /foo/bar is activated, all /foo/bar.* files are removed from the 
 
     # cache. 
 
     /invalidate 
 
     { 
 
     /0000 
 
      { 
 
      /glob "*" 
 
      /type "deny" 
 
      } 
 
     /0001 
 
      { 
 
      /glob "*.html" 
 
      /type "allow" 
 
      } 
 
     } 
 
     } 
 
    # the statistics define, how the load should be balanced among the renders 
 
    # according to the media-type. 
 
    /statistics 
 
     { 
 
     /categories 
 
     { 
 
     /html 
 
      { 
 
      /glob "*.html" 
 
      } 
 
     /others 
 
      { 
 
      /glob "*" 
 
      } 
 
     } 
 
     } 
 
    }

1

У вас есть два варианта, либо настройки Apache перенаправлять/на главную страницу (/ содержание/MyApp/дома .html или эквивалент) ИЛИ вы можете использовать заводские настройки ресурса resolver, чтобы переписать URL-адрес.

Для простой версии используйте сопоставления ресурса-резольвера. Увидеть этот пост для более подробной информации:

http://www.aemmastery.com/2015/03/15/aem-osgi-service-dive-resource-resolver-factory/

0

По умолчанию вы не позволяя ничего, используя этот фильтр.

# Deny everything first and then allow specific entries 
/0001 { /type "deny" /glob "*" } 

Следовательно/не допускается. Если вы хотите разрешить доступ к корню, вам нужно специально разрешить его, добавив строку

/0024 { /type "allow" /glob "* /*" } 
0

Конфигурация вашего диспетчера выглядит нормально. Чтобы проверить, работает ли диспетчер или нет, вы можете просто ввести следующий URL-адрес, чтобы увидеть, отображается ли страница, а затем проверить папку кэша.

http://localhost: {порт, если вы не используете 80 на апача)/содержание/{sitenode}

Пусть все вышеупомянутое работает при использовании локального сервера, то он должен быть вопросом конфигурации в ваш конфигурационный файл apache.

Проверьте следующие параметры четко определены в вашем диспетчерский разделе модуля

  • DispatcherDeclineRoot (Это определяет, следует ли отклонить запросы в корень «/»)
  • DispatcherUseProcessedURL (Это определяет, следует ли использовать предварительно обработанных URL-адресов для всей последующей обработки диспетчером)

ps Если вы заработаете, не забудьте поделиться некоторыми подробностями здесь. :)

0

Вам необходимо использовать mod_rewrite Apache Module, чтобы перенаправить ваш запрос с '/' на '/ content /'/en.html '
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Настоящая официальная документация содержит хорошее представление о том, как писать правила перезаписи.

кроме этого, потому что/не имеет расширения, говорится, что этот запрос не может быть кэширован. Я считаю, что вам не нужно ничего делать, кроме упомянутого перенаправления, поскольку en.html имеет «.html», поскольку его расширение и/0047 {/ type "allow"/glob "* * .html *"} уже упомянутые в разделе Фильтр

1

Вам может понадобиться виртуальный хост-файл, подобный следующему:

<VirtualHost *:80> 
    ServerName www.mywebapp.com 
    DocumentRoot /var/www/html 
    ErrorDocument 404 /content/mywebapp/en/404.html 
    ErrorDocument 500 /content/mywebapp/en/500.html 

    RewriteEngine On 
    RewriteLog "logs/rewrite-www-mywebapp-com.log" 
    RewriteLogLevel 1 

    RewriteRule ^/en.html$/[R=301,L] 
    RewriteRule ^/$ /content/mywebapp/en.html [PT] 

    RewriteCond %{REQUEST_URI} !^/etc(.*) [NC] 
    RewriteCond %{REQUEST_URI} !^/libs(.*) [NC] 
    RewriteCond %{REQUEST_URI} !^/content(.*) [NC] 
    RewriteCond %{REQUEST_URI} !^/system(.*) [NC] 
    RewriteCond %{REQUEST_URI} !^/dam(.*) [NC] 
    RewriteCond %{REQUEST_URI} !^/services(.*) [NC] 
    RewriteRule ^/(.*) /content/mywebapp/$1 [PT] 

    <Directory "/var/www/html"> 
     <IfModule disp_apache2.c> 
      SetHandler dispatcher-handler 
      ModMimeUsePathInfo On 
     </IfModule> 

      Options FollowSymLinks 
      AllowOverride AuthConfig 
      Order allow,deny 
      Allow from all 
    </Directory> 
</VirtualHost> 

Так что, если вы идете в www.mywebapp.com, файл/Var/WWW/HTML/содержание/mywebapp /en.html создается и кэшируется. Если вы заходите на сайт www.mywebbapp.com/en/foo/bar.html, создается и кэшируется файл /var/www/html/content/mywebapp/en/foo/bar.html.

Настроить приведенный выше файл, чтобы удовлетворить ваши собственные потребности.

Возможно, вам также понадобится настроить отображение/etc/mapping в соответствии с вашими требованиями к переписыванию URL-адресов. См. Эту страницу для получения дополнительной информации: https://docs.adobe.com/docs/en/aem/6-2/deploy/configuring/resource-mapping.html

0

Существует два способа решения проблемы.

1, В разделе фильтра добавьте правило ниже. /0001 { /type "allow" /glob "*" }

2, обычно в проектах реального времени у нас есть контент под /content/xyz.html, для такого сценария мы добавляем ниже правила.

`/0001 { /type "deny" /glob "*" }` 
`/0001 { /type "allow" /glob "/content/*" }` 

Добавить правило перезаписи, которое любая вещь после перенаправления URL-адреса на /content/xyz.html.

RewriteRule ^/(. *)/Содержание/mywebapp/$ 1 [R = 301, L]

продолжать добавлять отрицают и позволяют правила в соответствии с требованиями проекта.