Redirect HTTP to HTTPS

Business solution to host your own OpenVPN server with web management interface and bundled clients.
Post Reply
Grandmstrbud
OpenVpn Newbie
Posts: 8
Joined: Thu May 04, 2023 2:08 pm

Redirect HTTP to HTTPS

Post by Grandmstrbud » Thu May 04, 2023 2:11 pm

Hello, first off I'm not that skilled in Linux at all so that's what is bringing me here.

I followed this guide and having an issue

https://openvpn.net/vpn-server-resource ... -to-https/

When I get to the part of entering crotab-e I am able to edit the last line as directed and save it. However when I do a "screen -list" it says No Sockets found in /run/screen/S-root

According to the documentation it should have an output of this

There is a screen on:
700.port80redirect (03/16/2017 05:22:34 PM) (Detached)
1 Socket in /var/run/screen/S-root.

Any help would be great.

Grandmstrbud
OpenVpn Newbie
Posts: 8
Joined: Thu May 04, 2023 2:08 pm

Re: Redirect HTTP to HTTPS

Post by Grandmstrbud » Tue May 09, 2023 12:58 am

I was advised to ask on these forums

User avatar
openvpn_inc
OpenVPN Inc.
Posts: 1333
Joined: Tue Feb 16, 2021 10:41 am

Re: Redirect HTTP to HTTPS

Post by openvpn_inc » Tue May 16, 2023 11:00 am

Hello Grandmstrbud,

You may have missed this line:
Now, when you reboot the system, screen automatically starts and runs the Python script port80redirect.py. Screen is a program that runs apps in the background continuously without needing to sign in as a user.
The crontab line starts with @reboot which means at next reboot it will run the command to start the service that redirects HTTP to HTTPS. It won't start running right after adding the crontab entry. It will run on next reboot.

Kind regards,
Johan
Image OpenVPN Inc.
Answers provided by OpenVPN Inc. staff members here are provided on a voluntary best-effort basis, and no rights can be claimed on the basis of answers posted in this public forum. If you wish to get official support from OpenVPN Inc. please use the official support ticket system: https://openvpn.net/support

Grandmstrbud
OpenVpn Newbie
Posts: 8
Joined: Thu May 04, 2023 2:08 pm

Re: Redirect HTTP to HTTPS

Post by Grandmstrbud » Tue May 16, 2023 1:05 pm

I have restarted it since then and I don't see this running. The output is from after a restart.

User avatar
openvpn_inc
OpenVPN Inc.
Posts: 1333
Joined: Tue Feb 16, 2021 10:41 am

Re: Redirect HTTP to HTTPS

Post by openvpn_inc » Thu May 18, 2023 5:50 pm

Hello Grandmstrbud,

Then you should try to run the script on the command line with Python and see if it works correctly or not. It may be that screen starts, the Python scripts starts, and then quits because it has a problem starting, and then screen closes as well. Running the redirect script directly on the command line should give you some error information on what's wrong. Maybe port 80 is already taken or maybe Python is not properly available for some reason.

Kind regards,
Johan
Image OpenVPN Inc.
Answers provided by OpenVPN Inc. staff members here are provided on a voluntary best-effort basis, and no rights can be claimed on the basis of answers posted in this public forum. If you wish to get official support from OpenVPN Inc. please use the official support ticket system: https://openvpn.net/support

Grandmstrbud
OpenVpn Newbie
Posts: 8
Joined: Thu May 04, 2023 2:08 pm

Re: Redirect HTTP to HTTPS

Post by Grandmstrbud » Mon May 22, 2023 1:27 am

Hi there thanks for the reply. I installed this by the guide step by step and that is what I got. I am not familiar with Linux so I would not know how to check anything. This is the only thing installed so I don't think it's already taken but I wouldn't know for sure. I don't use this mich but it would be nice if it worked for me just because it's one of those things that was frustrating me that I couldn't get it I could attempt this again and get some screenshots

Grandmstrbud
OpenVpn Newbie
Posts: 8
Joined: Thu May 04, 2023 2:08 pm

Re: Redirect HTTP to HTTPS

Post by Grandmstrbud » Mon May 22, 2023 5:41 pm

This is the output of the screen -list command.

root@openvpnas2:~# screen -list
No Sockets found in /run/screen/S-root.

I followed everything from this guide as I posted above and that's what I get.

https://openvpn.net/vpn-server-resource ... -to-https/

skaneff
OpenVpn Newbie
Posts: 3
Joined: Fri Jun 02, 2023 2:30 pm

Re: Redirect HTTP to HTTPS

Post by skaneff » Fri Jun 02, 2023 2:35 pm

Hi, friend,
check your python version "python --version"

If you have the default 2.* version, then change the version in the system to 3.*
or just write in the crontab line whatever third version you have.

What worked for me was /usr/bin/screen -dmS port80redirect /usr/bin/python3.8 /usr/local/openvpn_as/port80redirect.py

You can see the availability of the Python version here: ls /usr/bin/ -la | grep python

Grandmstrbud
OpenVpn Newbie
Posts: 8
Joined: Thu May 04, 2023 2:08 pm

Re: Redirect HTTP to HTTPS

Post by Grandmstrbud » Fri Jun 02, 2023 4:42 pm

Thanks for the reply, I did that and restarted it and same message comes up with No Sockets found.


root@openvpnas2:~# python --version
Python 2.7.17
root@openvpnas2:~#

root@openvpnas2:~# ls /usr/bin/ -la | grep python
-rwxr-xr-x 1 root root 1056 Apr 16 2018 dh_python2
-rwxr-xr-x 1 root root 2336 Feb 21 2018 dh_python3-ply
lrwxrwxrwx 1 root root 23 Mar 8 12:40 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx 1 root root 23 Mar 10 10:46 pdb3.6 -> ../lib/python3.6/pdb.py
lrwxrwxrwx 1 root root 31 Oct 25 2018 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx 1 root root 9 Apr 16 2018 python -> python2.7
lrwxrwxrwx 1 root root 9 Apr 16 2018 python2 -> python2.7
-rwxr-xr-x 1 root root 3637096 Mar 8 12:40 python2.7
lrwxrwxrwx 1 root root 9 Oct 25 2018 python3 -> python3.6
-rwxr-xr-x 2 root root 4526456 Mar 10 10:46 python3.6
-rwxr-xr-x 2 root root 4526456 Mar 10 10:46 python3.6m
lrwxrwxrwx 1 root root 10 Oct 25 2018 python3m -> python3.6m
-rwxr-xr-x 1 root root 164 Nov 1 2017 python3-migrate
-rwxr-xr-x 1 root root 177 Nov 1 2017 python3-migrate-repository
-rwxr-xr-x 1 root root 152 Nov 11 2017 python3-pbr
lrwxrwxrwx 1 root root 29 Apr 16 2018 pyversions -> ../share/python/pyversions.py

skaneff
OpenVpn Newbie
Posts: 3
Joined: Fri Jun 02, 2023 2:30 pm

Re: Redirect HTTP to HTTPS

Post by skaneff » Fri Jun 02, 2023 5:00 pm

show netstat -tulpn

Grandmstrbud
OpenVpn Newbie
Posts: 8
Joined: Thu May 04, 2023 2:08 pm

Re: Redirect HTTP to HTTPS

Post by Grandmstrbud » Fri Jun 02, 2023 5:05 pm

root@openvpnas2:~# show netstat -tulpn
-bash: show: command not found
root@openvpnas2:~#

skaneff
OpenVpn Newbie
Posts: 3
Joined: Fri Jun 02, 2023 2:30 pm

Re: Redirect HTTP to HTTPS

Post by skaneff » Fri Jun 02, 2023 5:07 pm

"netstat -tulpn" without "show"

Grandmstrbud
OpenVpn Newbie
Posts: 8
Joined: Thu May 04, 2023 2:08 pm

Re: Redirect HTTP to HTTPS

Post by Grandmstrbud » Fri Jun 02, 2023 5:10 pm

I warned you I'm a dummy on Linux, :)

root@openvpnas2:~# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:943 0.0.0.0:* LISTEN 418/python3
tcp 0 0 0.0.0.0:914 0.0.0.0:* LISTEN 508/openvpn-openssl
tcp 0 0 0.0.0.0:915 0.0.0.0:* LISTEN 517/openvpn-openssl
tcp 0 0 0.0.0.0:916 0.0.0.0:* LISTEN 526/openvpn-openssl
tcp 0 0 0.0.0.0:917 0.0.0.0:* LISTEN 535/openvpn-openssl
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 271/systemd-resolve
tcp 0 0 0.0.0.0:918 0.0.0.0:* LISTEN 544/openvpn-openssl
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 323/sshd
tcp 0 0 0.0.0.0:919 0.0.0.0:* LISTEN 553/openvpn-openssl
tcp 0 0 0.0.0.0:920 0.0.0.0:* LISTEN 562/openvpn-openssl
tcp 0 0 0.0.0.0:921 0.0.0.0:* LISTEN 571/openvpn-openssl
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 380/smbd
tcp 0 0 127.0.0.1:904 0.0.0.0:* LISTEN 418/python3
tcp 0 0 127.0.0.1:905 0.0.0.0:* LISTEN 418/python3
tcp 0 0 127.0.0.1:906 0.0.0.0:* LISTEN 418/python3
tcp 0 0 127.0.0.1:907 0.0.0.0:* LISTEN 418/python3
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 380/smbd
tcp 0 0 127.0.0.1:908 0.0.0.0:* LISTEN 418/python3
tcp 0 0 127.0.0.1:909 0.0.0.0:* LISTEN 418/python3
tcp6 0 0 :::22 :::* LISTEN 323/sshd
tcp6 0 0 :::445 :::* LISTEN 380/smbd
tcp6 0 0 :::139 :::* LISTEN 380/smbd
udp 0 0 0.0.0.0:52281 0.0.0.0:* 377/python3
udp 0 0 127.0.0.53:53 0.0.0.0:* 271/systemd-resolve
udp 0 0 172.27.239.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.238.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.237.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.236.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.235.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.234.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.233.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.232.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.231.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.230.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.229.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.228.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.227.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.226.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.225.1:123 0.0.0.0:* 318/ntpd
udp 0 0 172.27.224.1:123 0.0.0.0:* 318/ntpd
udp 0 0 192.168.1.50:123 0.0.0.0:* 318/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 318/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 318/ntpd
udp 0 0 192.168.1.255:137 0.0.0.0:* 378/nmbd
udp 0 0 192.168.1.50:137 0.0.0.0:* 378/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 378/nmbd
udp 0 0 192.168.1.255:138 0.0.0.0:* 378/nmbd
udp 0 0 192.168.1.50:138 0.0.0.0:* 378/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 378/nmbd
udp 0 0 0.0.0.0:922 0.0.0.0:* 580/openvpn-openssl
udp 0 0 0.0.0.0:923 0.0.0.0:* 588/openvpn-openssl
udp 0 0 0.0.0.0:924 0.0.0.0:* 601/openvpn-openssl
udp 0 0 0.0.0.0:925 0.0.0.0:* 625/openvpn-openssl
udp 0 0 0.0.0.0:926 0.0.0.0:* 633/openvpn-openssl
udp 0 0 0.0.0.0:927 0.0.0.0:* 641/openvpn-openssl
udp 0 0 0.0.0.0:928 0.0.0.0:* 649/openvpn-openssl
udp 0 0 0.0.0.0:929 0.0.0.0:* 657/openvpn-openssl
udp6 0 0 fe80::f2c9:1816:870:123 :::* 318/ntpd
udp6 0 0 fe80::a687:4ae9:d0a:123 :::* 318/ntpd
udp6 0 0 fe80::1620:9413:b31:123 :::* 318/ntpd
udp6 0 0 fe80::b83:5baa:687b:123 :::* 318/ntpd
udp6 0 0 fe80::4d4a:9641:c63:123 :::* 318/ntpd
udp6 0 0 fe80::1af3:4180:c7f:123 :::* 318/ntpd
udp6 0 0 fe80::4f7:6dee:b3eb:123 :::* 318/ntpd
udp6 0 0 fe80::c964:d2a0:a8b:123 :::* 318/ntpd
udp6 0 0 fe80::bc43:e2a7:516:123 :::* 318/ntpd
udp6 0 0 fe80::b222:856:e73a:123 :::* 318/ntpd
udp6 0 0 fe80::3644:99fd:1d8:123 :::* 318/ntpd
udp6 0 0 fe80::ea5a:8fee:df2:123 :::* 318/ntpd
udp6 0 0 fe80::d63:2d7e:7287:123 :::* 318/ntpd
udp6 0 0 fe80::48d:bfb8:f271:123 :::* 318/ntpd
udp6 0 0 fe80::934b:4e0e:391:123 :::* 318/ntpd
udp6 0 0 fe80::c8b9:63d0:6f9:123 :::* 318/ntpd
udp6 0 0 fe80::443e:f4ff:fe1:123 :::* 318/ntpd
udp6 0 0 fe80::20c:29ff:fed2:123 :::* 318/ntpd
udp6 0 0 ::1:123 :::* 318/ntpd
udp6 0 0 :::123 :::* 318/ntpd
udp6 0 0 fe80::20c:29ff:fed2:546 :::* 263/systemd-network

Post Reply