Tuesday, May 17, 2016

iptables - Redirect from http to https

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 types http://ci.mydomain.com
it should be redirected to https://...



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 to https://ci.mydomain.com.

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...