当scheme为http且location为/
时,我想重定向到httpsserver {
listen 80;
server_name bla;
location / {
return 301 https://bla;
}
include fs.inc;
}
现在,问题是:fs.inc包括anothes“location /”,即使从未调用过nginx配置测试也会失败并显示错误duplicate location "/" in fs.inc:1
。
我该如何解决?
答案 0 :(得分:0)
您需要另一个服务器块:
server {
listen 443;
server_name bla; # make sure this is the same
# add your ssl specific directives here
location / {
alias /var/www/secured/;
}
}
server {
listen 80;
server_name bla;
return 301 https://$request_uri;
}
这是全局重定向