TOS web UI http to https redirect - how-to
Posted: 28 Feb 2021, 11:33
Something that's been frustrating me is the lack of an option to redirect TOS web UI traffic to https. Also that my https session now and then gets redirected to http but using the https port, resulting in a 400 error, though I haven't seen anyone else report this.
After some googling, I've found how to fix both these issues by updating the web server config file (nginx.conf) file via SSH and a text editor.
DO THIS AT YOUR OWN RISK
I have an F5-420, but this should work for anyone whose TNAS is running nginx as the web server.
I use PuTTY for SSH, and Notepad++ to edit the config file.
1. Log in as root via SSH
2. Navigate to the nginx folder
3. Copy nginx.conf to a share that you can access from another computer.
4. Rename nginx.conf so you have a backup of the original code.
Forward HTTP to HTTPS
5. Open nginx.conf in your preferred text editor, and locate this text:
6. Insert the line after so that it now looks like this:
7. Save the edited nginx.conf file, then copy it back to the nginx folder (MAKE SURE YOU RENAMED THE ORIGINAL FILE IN STEP 4 BEFORE THIS).
8. Stop and start the nginx service.
9. Open a web browser and navigate to http://<your TNAS IP>:8580 and it should redirect to https://<your TNAS IP>:5443
OPTIONAL: Forward HTTP port 5443 to HTTPS 5443
As I seem to be the only person getting this error, you may not need to do this part.
10. Open nginx.conf in your preferred text editor, and locate this text:
11. Insert the line after so that it now looks like this:
12. Save the edited nginx.conf file, then copy it back to the nginx folder (MAKE SURE YOU RENAMED THE ORIGINAL FILE IN STEP 4 BEFORE THIS).
13. Stop and start the nginx service.
14. Open a web browser and navigate to http://<your TNAS IP>:5443 and it should redirect to https://<your TNAS IP>:5443
After some googling, I've found how to fix both these issues by updating the web server config file (nginx.conf) file via SSH and a text editor.
DO THIS AT YOUR OWN RISK
I have an F5-420, but this should work for anyone whose TNAS is running nginx as the web server.
I use PuTTY for SSH, and Notepad++ to edit the config file.
1. Log in as root via SSH
2. Navigate to the nginx folder
Code: Select all
cd /etc/nginxCode: Select all
cp nginx.conf /mnt/md0/<your share here>/Code: Select all
mv nginx.conf nginx-original.conf5. Open nginx.conf in your preferred text editor, and locate this text:
Code: Select all
#HTTP server
server {
listen 8580;
include nginx-ipv6.conf;
server_name znasnginx;
root /usr/www/;
index index.html index.htm index.php;Code: Select all
return 301 https://$host:5443$request_uri;Code: Select all
server_name znasnginx;Code: Select all
#HTTP server
server {
listen 8580;
include nginx-ipv6.conf;
server_name znasnginx;
return 301 https://$host:5443$request_uri;
root /usr/www/;
index index.html index.htm index.php;Code: Select all
cp /mnt/md0/<your share here>/nginx.conf /etc/nginx/Code: Select all
service nginx stop
service nginx startOPTIONAL: Forward HTTP port 5443 to HTTPS 5443
As I seem to be the only person getting this error, you may not need to do this part.
10. Open nginx.conf in your preferred text editor, and locate this text:
Code: Select all
#HTTPS server
server {
listen 5443;
include nginx-ipv6-https.conf;
server_name znasnginx;
root /usr/www/;
index index.html index.htm index.php;Code: Select all
error_page 497 https://$host:$server_port$request_uri;Code: Select all
index index.html index.htm index.php;Code: Select all
#HTTPS server
server {
listen 5443;
include nginx-ipv6-https.conf;
server_name znasnginx;
root /usr/www/;
index index.html index.htm index.php;
error_page 497 https://$host:$server_port$request_uri;Code: Select all
cp /mnt/md0/<your share here>/nginx.conf /etc/nginx/Code: Select all
service nginx stop
service nginx start