rejetto forum
Software => HFS ~ HTTP File Server => router & port problems => Topic started by: eyespeak on June 02, 2017, 07:52:55 PM
-
Hi,
i have generated with Stunnel and Let´s Encrypt my own certificate without a SSL warning. Nice :-)
Now: how i can redirect alway all requests from port 80 to port 443?
Thanks a lot.
-
iptables /nat traffice to via port forwarding starting port 80 to ending pot 443.
or
have a port 80 webpage that redirects you to the https site.
https://stackoverflow.com/questions/5411538/redirect-from-an-html-page
html code:
<meta http-equiv="refresh" content="0; url=http://example.com/" />
-
@eyespeak: I guess you own a domain, right?...
...or you are only using a DynDNS service (like No-IP)?
If you are using a domain, please say us what registrar are you using.
If you can give us more details, it would be more easy to help you. ;)
-
<meta http-equiv="refresh" content="0; url=http://example.com/" />
Ok, it works but i have now a endless loop between http<>https. Not so good :)
-
@eyespeak: I guess you own a domain, right?...
...or you are only using a DynDNS service (like No-IP)?
Yes, own domain with subdomain. I connect with sub.domain.de
If you are using a domain, please say us what registrar are you using.
My router has an account from selfhost.de, and my provider a CNAME entry on this subdomain. It works fine.
But how can I now only connect to https? The only way so far ... Only NAT 443 to internal:
NOT Working http://sub.mydomain.de
Working https://sub.mydomain.de
But I want to redirect from http to https directly:
http to https
https stay https
-
I'm not familiar with SelfHost.de (http://selfhost.de/) but you can try this code:
<html>
<head>
<script language="JavaScript">
if (window.location.href.indexOf('http://')==0)
window.location=window.location.href.replace('http://','https://');
</script>
</head>
<body>
</body>
</html>
Insert the code marked in red in the <head> section (source (https://stackoverflow.com/a/4954784)).
-
I'm not familiar with SelfHost.de (http://selfhost.de/) but you can try this code:Insert the code marked in red in the <head> section (source (https://stackoverflow.com/a/4954784)).
Fine, the snippet works!
Is there any other option without JavaScript?
-
Is there any other option without JavaScript?
Probably using Macros, but I don't know if can be done. You can find another solution, here (http://www.rejetto.com/forum/router-port-problems/redirection-httpaaaaa-aaa-en-httpsaaaaa-aaa/msg1017656/#msg1017656) and also here (http://www.rejetto.com/forum/hfs-~-http-file-server/problem-with-downloading-and-accessing-server/msg1035500/#msg1035500).
-
Stunnel accepts only the ssl (HTTPS) request, if you want a http request to be redirected to https, a server listening on port 80 must redirect the url to the stunnel 443 port. You can run hfs listening only on address:port as 127.0.0.1:8443 with in stunnel a config like
[https]
accept = 0.0.0.0:443
connect = 127.0.0.1:8443
.....
you can use a second hfs stored in another folder ( not the same of the default server) to redirect request.
this hfs must have his options saved to disk and hear port 80, no file in vfs and root template can be defined in diff template as
[=not found]
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="5; url=https://sub.mydomain.de{.get|url.}">
<title>Page Redirection</title>
</head>
<body>
You will be redirected automatically to<p>
https://sub.mydomain.de{.get|url.} in 5 second
</body>
</html>
all request http on port 80 are redirected to stunnel on port 443
-
The 0 should be a 1. In meta refresh rate the info loop is due to the page not fully loading.
As Mars has posted it's 5 seconds​ before refresh