Redirect from http to https
Solution 1
iptables IS NOT what you want here -- You are sending a browser that is expecting to talk plain-old HTTP (just boring ordinary text) to a server that is talking HTTPS (encrypted, and VERY confusing for your browser).
You want a 300-series Redirect issued by your web server to send the client to the appropriate https:// URL. If you are running Apache you can combine this with the SSLRequireSSL
directive (Manual Entry) to ensure that your clients cannot access resources that should be encrypted over unencrypted channels.
Solution 2
HTTP and HTTPS are different application level protocols, so you can't just redirect on a transport level. You should set up Apache or Nginx or something on port 80 to perform a proper HTTP redirect using a Location
header.
Solution 3
Setup a relatively blank VirtualHost listening on 80, which does nothing but
RewriteEngine On
RewriteRule (.*) https://foo.com$1
Solution 4
Going from http to https is more then just switching ports. These are two different protocols and your Hudson/Jenkins installation is looking for https and not http.
I don't know of a way to do what you want without installing something like Apache to listen on port 80.
Solution 5
You are probably at an impasse here as http & https are dissimilar enough where a simple port redirect is not going to work.
Related videos on Youtube
Comments
-
Tim over 1 year
I have a Hudson/Jenkins installation which runs on port 443, so I can access it with
https://ci.mydomain.com
. I do not have a webserver running on port 80 like Apache Httpd, but I want if a user typeshttp://ci.mydomain.com
it should be redirected tohttps://...
I tried it with
iptables
:/sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 443 /sbin/iptables-save chkconfig --level 35 iptables on
But the browser tells me, that the connection failed. So I do not want to install Apache webserver, I only want to have a redirect from
http://ci.mydomain.com
tohttps://ci.mydomain.com
.-
Tim almost 13 yearsOkay I have to install sth. like Apache. And then, what is the best way to redirect?
-