Facebook 无法使用Nginx+;预渲染&x2B;流星
我在配置nginx以在使用HTTPS时返回预呈现的html时遇到问题Facebook 无法使用Nginx+;预渲染&x2B;流星,facebook,meteor,nginx,prerender,Facebook,Meteor,Nginx,Prerender,我在配置nginx以在使用HTTPS时返回预呈现的html时遇到问题 nginx、prerender和my meteor应用程序在同一台服务器上运行 prerender位于端口3033中 meteor应用程序位于端口112 在meteor中,我将其配置为指向localhost:3033进行预渲染 通过以下无SSL配置,Facebook能够成功抓取我的网站: server { listen 80; server_name sample.com www.sample.com;
- nginx、prerender和my meteor应用程序在同一台服务器上运行李>
- prerender位于端口3033中
- meteor应用程序位于端口112
server {
listen 80;
server_name sample.com www.sample.com;
# strip the "www" subdomain
if ($host ~* ^www\.(.*)) {
set $host_without_www $1;
rewrite ^(.*) http://$host_without_www$1 permanent;
}
location / {
# app is running in port 112 in the same server
proxy_pass http://127.0.0.1:112;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
然而,当我开始使用SSL时,Facebook无法抓取该网站
server {
listen 443 ssl;
server_name sample.com www.sample.com;
ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
# strip the "www" subdomain
if ($host ~* ^www\.(.*)) {
set $host_without_www $1;
rewrite ^(.*) http://$host_without_www$1 permanent;
}
location ~ /.well-known {
allow all;
}
location / {
# app is running in port 112 in the same server
proxy_pass http://127.0.0.1:112;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
# redirect to https
server {
listen 80;
server_name sample.com www.sample.com;
return 301 https://$host$request_uri;
}
一个观察结果是,每次我运行带有HTTPS的FB工具时,都会说https://sample.com/
,在预渲染日志中,它表示获取http://sample.com
(不是HTTPS!)
手动运行curl
命令成功
curlhttp://sample.com:3033/https://sample.com
在这两者之间的某个地方显然正在将协议
https
转换为http
听起来像是在负载平衡器或类似的地方终止SSL。在prerender配置中,将URL发送到prerender服务器时,您应该强制协议为https。听起来像是在负载平衡器或类似设备上终止SSL。在prerender配置中,当将URL发送到prerender服务器时,您应该强制协议为https。看来我的nginx配置还是不错的
我最终遵循了代码
meteor npm安装--保存预渲染节点
{
"PrerenderIO": {
"serviceUrl": "http://localhost:3033/",
"token": "yourtoken"
}
}
看来我的nginx配置还是不错的 我最终遵循了代码
meteor npm安装--保存预渲染节点
{
"PrerenderIO": {
"serviceUrl": "http://localhost:3033/",
"token": "yourtoken"
}
}
您在预呈现内容的开放图形元标记中指定了什么
og:url
值?您在预呈现内容的开放图形元标记中指定了什么og:url
值?谢谢您的回答。我能解决我的问题,就像你建议的一样。谢谢你的回答。我能像你建议的那样解决我的问题