I will explain how to redirect all http proxied connections (External Applications) of a Synology NAS.
First of all you need to login by ssh to the NAS and create a file in the filesystem path /etc/nginx/conf.d/
with a name that stats with “www
.” and ends with “.conf
“. I did with vim in the following way:
sudo vim /etc/nginx/conf.d/www.http2https.conf}
Paste next content to the file:
if ($scheme = http) {
return 301 https://$http_host$request_uri;
}
Now restart Nginx service:
/usr/syno/sbin/synoservicecfg --restart nginx
Et Voilà! Now when yo add a proxied application you do not need to create a vhost or create two 3rd apps to have your service through http and https. Just create the proxy connection with the hostname once.
Very useful if you have a wildcard cert in your NAS.
UPDATE: Modified the nginx configuration. Where now says “$http_host” was previously with “$server_name”. This makes the redirection always to https://_ instead of the requested hostname but with this change all runs like a champ! 😅