Synology HTTP to HTTPS redirect

Last modified date

Comments: 0

When http or https isn’t entered as part of an address most internet browsers will default to port 80 (http) and attempt to load the page. This is no good when your website or docker container is behind an SSL certificate as the page will fail to load. This is where you need the address entered to automatically redirect to https and load the page.

This is a not a full end to end guide for setting up a public domain with an SSL certificate, it assumes you are already able to access your page when including https in the address but fails without.

  1. Install Apache 2.4 from Package Centre on your Synology NAS, this will automatically include the installation of Web Station which is also required.
  2. When Web Station is installed a folder called ‘web’ is created on your NAS. Create a folder in here (can be called anything you wish).
  1. For this next part I will give instructions for a Windows user but it can be done on any OS. Create a text file on your desktop by right clicking and choosing New-Text Document. Rename the newly created file .htaccess. Right click on the file and open it in notepad and copy in the text below.
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  1. Save this file and move it to the newly created folder within the web folder on your NAS.
  2. Next we need to create a Virtual Host on your NAS. Load up the Web Station package installed previously and create a Virtual Host as shown in the screenshot. The Port can be anything you want but make note of it as it’ll be used later.
  1. Now when you enter your address into your browser without https you should see the webstation logo rather than a browser error
  1. Now for each of your applications/sites you’ll need to set up a reverse proxy rule as follows. In Control Panel – Application Portal – Reverse Proxy set up a new rule as below with the port you used in the Virtual Host (1234 in this example). In the host name box enter the address without http(s).

Now when you enter the address your NAS will automatically redirect it to your https address.


Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment