TOS web UI http to https redirect - how-to

Language, region, time zone, power, navigation, notification and more.
Locked
User avatar
justsimon
Posts: 69
Joined: 22 Sep 2020, 15:18

TOS web UI http to https redirect - how-to

Post by justsimon »

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

Code: Select all

cd /etc/nginx
3. Copy nginx.conf to a share that you can access from another computer.

Code: Select all

cp nginx.conf /mnt/md0/<your share here>/
4. Rename nginx.conf so you have a backup of the original code.

Code: Select all

mv nginx.conf nginx-original.conf
Forward HTTP to HTTPS
5. 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;
6. Insert the line

Code: Select all

return 301 https://$host:5443$request_uri;
after

Code: Select all

server_name znasnginx;
so that it now looks like this:

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;
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).

Code: Select all

cp /mnt/md0/<your share here>/nginx.conf /etc/nginx/
8. Stop and start the nginx service.

Code: Select all

service nginx stop
service nginx start
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:

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;
11. Insert the line

Code: Select all

error_page 497 https://$host:$server_port$request_uri;
after

Code: Select all

index  index.html index.htm index.php;
so that it now looks like this:

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;
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).

Code: Select all

cp /mnt/md0/<your share here>/nginx.conf /etc/nginx/
13. Stop and start the nginx service.

Code: Select all

service nginx stop
service nginx start
14. Open a web browser and navigate to http://<your TNAS IP>:5443 and it should redirect to https://<your TNAS IP>:5443
User avatar
justsimon
Posts: 69
Joined: 22 Sep 2020, 15:18

Re: TOS web UI http to https redirect - how-to

Post by justsimon »

So this post has/had been viewed 80 times.

Is anyone finding this useful?
If you are, or aren't, can you post any feedback?

I'd love for this to gain some traction and then hopefully Terra-Master can dedicate some time to developing web UI functionality to do this.

Cheers,

-justsimon
User avatar
Spaniard
Posts: 19
Joined: 26 Dec 2020, 00:28

Re: TOS web UI http to https redirect - how-to

Post by Spaniard »

Hi,
Thanks for the info. It would be nice if the forum had a "like" or "thanks" function for posts like this. Keeps threads tidy and provides feedback without making dozens of boring "+1" lines.
User avatar
konst82
Posts: 1
Joined: 27 Mar 2021, 02:09

Re: TOS web UI http to https redirect - how-to

Post by konst82 »

Hi.
Thanks for the tip. I think everyone needs to configure this.
User avatar
TMroy
TerraMaster Team
Posts: 2605
Joined: 10 Mar 2020, 14:04
China

Re: TOS web UI http to https redirect - how-to

Post by TMroy »

Thnak you! we already added it to our plan list.
To contact our team, please send email to following addresses, remember to replace (at) with @:
Support team: support(at)terra-master.com (for technical support only)
Service team: service(at)terra-master.com (for purchasing, return, replacement, RMA service)
User avatar
justsimon
Posts: 69
Joined: 22 Sep 2020, 15:18

Re: TOS web UI http to https redirect - how-to

Post by justsimon »

Awesome!
Any chance you can publish the plan list?
Locked

Return to “System Configuration”