【问题标题】:Facebook not able to scrape my secured url (Nginx)Facebook 无法抓取我的安全网址(Nginx)
【发布时间】:2025-12-11 07:30:02
【问题描述】:

我有一个 Node.js 应用程序在 Ubuntu 服务器上运行,并使用 Let's Encrypt 配置了 SSL 配置的 Nginx 设置。

我的 Nginx 配置文件如下所示:

server {

server_name www.example.be example.be;
location / {
        proxy_pass http://localhost:3485;
        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;
    }

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.be/fullchain.pem; # managed by C$
ssl_certificate_key /etc/letsencrypt/live/example.be/privkey.pem; # managed by$
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
   if ($host = www.example.be) {
      return 301 https://$host$request_uri;
   } # managed by Certbot


   if ($host = example.be) {
      return 301 https://$host$request_uri;
   } # managed by Certbot


   listen 80;
   server_name www.example.be example.be;
   return 404; # managed by Certbot
}

没有 SSL,Facebook 完全可以抓取我的网址,但是当我激活 SSL 然后在 Facebook 共享调试器中提交它时,我收到以下错误:

无法跟随重定向:URL 请求了 HTTP 重定向,但无法跟随。

循环重定向:我们无法解析规范 URL,因为重定向路径包含一个循环。

重定向路径

输入网址 -> https://www.example.be

301 HTTP 重定向 -> https://www.example.be

另外,我对 Google 的 PageSpeed 洞察也有同样的问题。我遇到的错误是“尝试加载页面已达到 10 个重定向的限制”

感谢您的任何建议!

【问题讨论】:

    标签: node.js facebook ssl nginx lets-encrypt


    【解决方案1】:

    将 https 强制重定向更改为此

    if ($http_x_forwarded_proto = "http") { return 301 https://$host$request_uri; }

    【讨论】: