我在我的Meteor APP上使用prerender-node,当我在本地测试抓取时,我有localhost:3000/http://stephane-richin.fr
的302状态代码:
2016-09-20T07:43:13.953Z got 302 in 329ms for http://stephane-richin.fr/
如果我使用'www'进行测试:localhost:3000/http://www.stephane-richin.fr
,状态代码为200(正确无误):
2016-09-20T07:46:59.685Z got 200 in 1570ms for http://www.stephane-richin.fr/
所以我觉得我的Ngix配置不好:
server {
listen *:80;
server_name www.stephane-richin.fr;
access_log /var/log/nginx/app.dev.access.log;
error_log /var/log/nginx/app.dev.error.log;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $remote_addr;
}
location @prerender {
proxy_set_header X-Prerender-Token xxxxxxxxxxx;
set $prerender 0;
if ($http_user_agent ~* "baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link previ$
set $prerender 1;
}
if ($args ~ "_escaped_fragment_") {
set $prerender 1;
}
if ($http_user_agent ~ "Prerender") {
set $prerender 0;
}
if ($uri ~* "\.(js|css|xml|less|png|jpg|jpeg|gif|pdf|doc|txt|ico|rss|zip|mp3|rar|exe|wmv|doc|avi|ppt|mpg|mpeg|tif$
set $prerender 0;
}
resolver 8.8.8.8;
if ($prerender = 1) {
set $prerender "service.prerender.io";
rewrite .* /$scheme://$host$request_uri? break;
proxy_pass http://$prerender;
}
if ($prerender = 0) {
rewrite .* /index.html break;
}
}
}
server {
listen *:80;
server_name stephane-richin.fr;
location / {
if ($http_host ~ "^([^\.]+)\.([^\.]+)$"){
rewrite ^/(.*) http://www.stephane-richin.fr/$1 redirect;
}
}
}
任何人都可以帮我解决我的配置Nginx问题?我认为问题是这个。
谢谢!