Facebook 无法抓取我的安全 url (Nginx)

Facebook not able to scrape my secured url (Nginx)

我在 Ubuntu 服务器上有一个 Node.js 应用程序 运行,使用 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 完全可以抓取我的 url,但是当我激活 SSL 然后在 Facebook Sharing Debugger 中提交它时,我收到以下错误:

无法遵循重定向:URL 请求了 HTTP 重定向,但无法遵循。

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

重定向路径

输入URL -> https://www.example.be

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

此外,我对 Google 的 PageSpeed 见解也有完全相同的问题。我得到的错误是 "Attempting to load page reached the limit of 10 redirects"

感谢您的任何建议!

将 https 强制重定向更改为此

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