簡體   English   中英

AEM :: Dispatcher問題

[英]AEM::Dispatcher issue

我已經在AEM上的本地計算機上配置了調度程序,現在嘗試使用URL http://www.mywebapp.com (此條目也是在hosts文件中創建的)。 這是我得到的錯誤

[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 "*"
          }
        }
      }
    }
  }

您應該讓mod_rewrite將“ GET /”請求重定向到“ GET /content/mywebapp/en.html”(以及其他規則)。 無法緩存“ GET /”,因為它沒有任何擴展名,並且您可能希望緩存主頁。

您有兩種選擇,要么是設置apache來將/重定向到您的主頁(/content/myapp/home.html或等效的頁面),要么可以使用資源解析器的出廠設置來重寫url。

對於簡單版本,請使用資源解析器映射。 有關更多詳細信息,請參見此帖子:

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

您可能需要類似於以下內容的虛擬主機文件:

<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/content/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/zh/aem/6-2/deploy/configuring/resource-mapping.html

這是我們為其中一個污染場地所做的示例

  # 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 "*" } } } } 

默認情況下,您不允許使用此過濾器。

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

因此,/是不允許的。 如果要允許訪問root用戶,則需要通過添加以下行來專門允許它

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

您的調度程序配置看起來不錯。 要驗證調度程序是否正常運行,您只需輸入以下URL以查看頁面是否正在顯示,然后檢查緩存文件夾。

http:// localhost :{端口(如果您未在Apache上使用80)/ content / {sitenode}

假設使用localhost時上述所有內容均正常運行,則必須是apache配置文件中的配置問題。

檢查在調度程序模塊部分中仔細定義的以下設置

  • DispatcherDeclineRoot(這定義是否拒絕對根“ /”的請求)
  • DispatcherUseProcessedURL(這定義是否將預處理的URL用於Dispatcher的所有進一步處理)

ps如果使它起作用,請不要忘記在此處分享一些細節。 :)

您需要使用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,在過濾器部分添加以下規則。 /0001 { /type "allow" /glob "*" }

2,通常在實時項目中,我們在/content/xyz.html下有內容,對於這種情況,我們添加以下規則。

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

添加一個重寫規則,URL之后的任何內容都將重定向到/content/xyz.html。

RewriteRule ^ /(。*)/ content / mywebapp / $ 1 [R = 301,L]

繼續添加拒絕並根據項目要求允許規則。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM