2017-05-13 9 views
2

정보 :미리 렌더링 + AngularJS와 - 크롤러 시간 설정에 대한 아웃

내가 설치 한 사전 렌더링 (https://github.com/prerender/prerender) 성공적으로 내 자신의 서버, 우분투 16.

이 내 htaccess로는, 그것은 다시 작성됩니다 크롤러가 감지 될 때 URL을 미리 렌더링합니다. 예 : 사전 렌더링을 사용할 때

메타 데이터 스카이프 레딧, 센터로드되지 : http://www.example.nl/63/Merryhttp://example.nl:3000/http://www.example.nl/63/Merry

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 

RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|redditbot|slackbot|msnbot|googlebot|duckduckbot|bingbot|rogerbot|linkedinbot|embedly|flipboard|tumblr|bitlybot|SkypeUriPreview|nuzzel|Discordbot|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR] 
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=$ 
RewriteRule ^(.*)$ http://example.nl:3000/http://www.example.nl/$1? [R=301,L] 
#RewriteRule ^(.*)$ http://art.example.net/$1? [R=301,L] 

RewriteRule ^(.*)/(.*)$ /#$1/$2 [NC,L] 

문제가된다. 오래된 PHP 웹 사이트에 URL을 다시 작성하십시오 : http://art.example.net (현재 htaccess에 주석 처리 됨)가 작동합니다. PHP와 Angular 웹 사이트의 모든 메타 태그가 동일하기 때문에 사전 확인자가 문제의 원인 일 가능성이 큽니다. 미리 렌더링을 사용하여 : (http://example.nl/63/Merry URL을 사용하여 https://cards-dev.twitter.com/validator) : 트위터에서

오류 예를

ERROR: Failed to fetch page due to: HttpConnectionTimeout 
WARN: this card is redirected to http://example.nl:3000/http://www.example.nl/63/Merry 

트위터 (또한 주요 URL 사용 : http://example.nl/63/Merry) art.example.net로 리디렉션

INFO: Page fetched successfully 
INFO: 19 metatags were found 
INFO: twitter:card = summary_large_image tag found 
INFO: Card loaded successfully 
WARN: this card is redirected to http://art.example.net/63/Merry 

을 PHP 버전을 사용하면 모든 메타 데이터가로드됩니다.

앞으로 PHP 웹 사이트를 완전히 제거하고 싶습니다. 그래서 Prerender와 함께 작업하는 것이 좋습니다. Prerender는 Discord 및 Postman (수정 된 사용자 에이전트 헤더 포함)에서 작동합니다. 나는 왜 그것이 다른 몇몇 대리인을 위해 작동하지 않는지 왜 모른다.

답변

1

재 작성 규칙은 리디렉션이 아닌 프록시 여야합니다. 사전 렌더링 서버로 리디렉션하면 검색 결과에서 사용자를 프리렌더 서버로 바로 보내도록 Google에 알리는 것과 같이 모든 종류의 문제가 발생합니다 (정말 좋지 않습니다!).

다시 쓰기 규칙 부분은 다음과 같아야합니다

RewriteRule ^(.*)$ http://example.nl:3000/http://www.example.nl/$1? [P,L] 
0

솔루션 :

트위터와 다른 크롤러 점과를 처리 할 수 ​​없습니다 ':'URL을한다. 그래서 일반 IP 주소와 포트 번호는 허용되지 않습니다.

이 문제를 해결하려면, 당신은 Node.js를 응용 프로그램에 리디렉션 하위 도메인을 만들 수 있습니다

내 하위 도메인 아파치 가상 호스트 : 대답에서 함께

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName prerender.example.net 
    ServerAlias prerender.example.net 
    ProxyPass/http://localhost:3000/ connectiontimeout=5 timeout=30 
</VirtualHost> 

https://serverfault.com/questions/497856/using-an-apache-virtualhost-to-access-a-node-js-instance-on-the-same-server

prerender.io 그들 자신, 나는 그것을 작동하게 만들었다.

비록 프록시와 리디렉션은 이미 소셜 미디어 크롤러에게 중요하지 않지만 URL은 이미 붙여져 있습니다. Proxy 태그를 사용하는 것이 좋습니다.