Reputation: 746
I want to redirect to https when scheme is http and location is /
server {
listen 80;
server_name bla;
location / {
return 301 https://bla;
}
include fs.inc;
}
Now, problem is: fs.inc includes anothes "location /" and even if this is never called the nginx configuration test fails with error duplicate location "/" in fs.inc:1
.
How can I solve that?
Upvotes: 0
Views: 4970
Reputation: 174624
You need another server block:
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;
}
This is a global redirect
Upvotes: 1