NgInx 和 NodeJs 部署获取响应代码 418

问题描述 投票:0回答:1

我在 NodeJS、EJS 中创建应用程序,并使用 Nginx 部署在 Ec2 上。我使用默认的 nginx 配置进行部署。一切都工作正常,但是,在 Facebook 调试工具上测试时,我收到 418 响应代码错误

enter image description here

由于此响应代码元标记未加载。

我尝试更改配置,但不起作用

nginx 配置文件:

server {
     listen 80 default_server;
     listen [::]:80 default_server;
     return 301 https://$host$request_uri; 
} 
server {     
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;
    ssl_certificate **path**;
    ssl_certificate_key /etc/ssl/private/****.key;
    server_name default_server;
    # Replace with your actual domain or IP
    location / {         
    proxy_pass http://localhost:4000/;         
    proxy_set_header Host $host;         
    proxy_set_header X-Real-IP $remote_addr;         
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;         
    proxy_set_header X-Forwarded-Proto $scheme;
    }     
    # Additional SSL settings for better security
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers off;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000" always;
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-XSS-Protection "1; mode=block"; 
}
javascript node.js nginx deployment nginx-config
1个回答
0
投票

我也遇到了同样的问题,在深入研究 facebook 调试器社区后,我发现这可能是由 SSL 配置问题引起的。 https://developers.facebook.com/community/threads/236322676147499/ 您应该在 https://www.sslshopper.com/ssl-checker.html.

检查您的 SSL 配置是否正确
© www.soinside.com 2019 - 2024. All rights reserved.