The top level server redirect from http to https doesn't work with the following nginx site configuration
Testcase:
1) Open the browser http://example.org
2) The server doesn't redirect to https://example.org
Adding 'return 301 https://$host$request_uri;' has no effect either.
```
upstream backend {
server localhost:8080;
}
upstream frontend {
server localhost:3000;
}
server {
listen 80;
server_name localhost
vagrant;
location ~ /\+\+api\+\+($|/.*) {
rewrite ^/\+\+api\+\+($|/.*) /VirtualHostBase/http/$server_name/Plone/++api++/VirtualHostRoot/$1 break;
proxy_pass http://backend;
}
location ~ / {
location ~* \.(js|jsx|css|less|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
expires +1y;
proxy_pass http://frontend;
}
location ~* static.*\.(ico|jpg|jpeg|png|gif|svg)$ {
add_header Cache-Control "public";
expires +1y;
proxy_pass http://frontend;
}
location ~ /(@@download|@@images|@@ical_view) {
rewrite ^(.*) /VirtualHostBase/http/$server_name/Plone/VirtualHostRoot$1 break;
proxy_pass http://backend;
break;
}
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;
proxy_redirect http:// https://;
proxy_pass http://frontend;
}
}
```
https://github.com/ericof/training-deploy-project/blob/main/ansible/files/nginx/default