“降级时无推荐人"nginx 502 [英] "No-referrer-when-downgrade" Nginx 502

查看:26
本文介绍了“降级时无推荐人"nginx 502的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我网站的某些页面出现 502 错误,我不明白为什么有些页面可以工作,而其他页面却显示此错误:

I have a 502 error on some pages of my site, I do not understand why some pages work but others display this error:

请求方式:POST状态码:502 Bad Gateway推荐人政策:降级时不推荐人

Request Method:POST Status Code:502 Bad Gateway Referrer Policy:no-referrer-when-downgrade

推荐答案

问题

您已将推荐人政策设置为no-referer-when-降级"在 Nginx 中,这意味着在降级(httpS 提交到简单的 http)的情况下不会发送引用信息(作为您的表单 URL).而你背后的代码不喜欢没有这条信息.

Problem

You have the Referer Policy set to "no-referer-when-downgrade" in Nginx, which means referer information (as your form URL) is not sent in case of downgrade (httpS submitting to simple http). And your code behind doesn't like not having this piece of information.

  1. 最好将所有内容都传递给 https :)

在你的 nginx.conf 中更改策略:

Change in your nginx.conf, the policy to:

 add_header 'Referrer-Policy' 'same-origin';

  • 如果 2. 不起作用,请按照 1. 中所述进行操作,或者您也可以(但请不要这样做,这是非常不安全的):

  • If 2. doesn't work, please do as said in 1., or you can also (but please don't do that, it's very unsecure):

     add_header 'Referrer-Policy' 'unsafe-url';
    


  • 更多:Mozilla 关于推荐人政策的参考文档.

    注意:origin 只会设置没有 URI 的基本 URL,例如 https://domain-name.com/.如果 same-origin 来自同一个域,它会将完整的安全 URL 设置为 Referer.它是安全的,因为标头是通过 :433 安全端口侦听传递的.

    Note: origin will only set the base URL with no URI like https://domain-name.com/. While same-origin will set the full Secure URL as the Referer if it's from the same domain. It's secure since the header is passed on the :433 secure port listening.

    这篇关于“降级时无推荐人"nginx 502的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆