使用querystring的ngnix https重定向
我已经在我的服务器上安装了ssl,它工作正常,但问题是,如果任何用户尝试在没有https的情况下访问站点,那么他/她将被重定向到没有查询字符串的https 仅此而已,它不使用查询字符串重定向。我试图添加以下代码,但它不工作使用querystring的ngnix https重定向,http,redirect,nginx,https,Http,Redirect,Nginx,Https,我已经在我的服务器上安装了ssl,它工作正常,但问题是,如果任何用户尝试在没有https的情况下访问站点,那么他/她将被重定向到没有查询字符串的https 仅此而已,它不使用查询字符串重定向。我试图添加以下代码,但它不工作 if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; } 我的conf文件在下面,有人可以帮忙吗 上游mysitecombackend{ 服务
if ($http_x_forwarded_proto = "http") {
return 301 https://$server_name$request_uri;
}
我的conf文件在下面,有人可以帮忙吗
上游mysitecombackend{
服务器unix:/var/run/php-fcgi-mysitecom.sock;
}
您从未将
$http\u x\u forwarded\u proto
设置为http
,因此if
条件始终为false
您可以尝试将变量与https进行比较,例如:
if ($http_x_forwarded_proto != "https") {
return 301 https://$server_name$request_uri;
}
if ($http_x_forwarded_proto != "https") {
return 301 https://$server_name$request_uri;
}