0

I am trying to configure my first https, and i think i get it, but there is a problem: the site wont open in http, just https, because of this, i want redirect everything to https.

I am using iptables, and this is my rules:enter image description here

This is my website: https://pubcrawlsp.com

Could someone give me a light here?

I already try use:

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 443
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 443 

I am using a EC2 instance, from amazon web services. [Ubuntu]

1
  • Despite what you say, it looks like now your HTTP site is available, but port 443 is closed. If so, and you are not already using Apache, check the node.js documentation at nodejs.org/api/https.html.
    – Cedric Knight
    Feb 22, 2015 at 9:51

2 Answers 2

4

You don't need to use your firewall for this, use apache to do the redirect

<VirtualHost *:80> ServerName www.example.com
Redirect / https://www.example.com/
</VirtualHost > 
<VirtualHost *:443> ServerName www.example.com

# ... SSL configuration goes here
</VirtualHost >
1
  • hm, do you know any tutorial that help me step by step Lain? I really don't know how to use apache
    – user416106
    Feb 22, 2015 at 6:12
0

Users might not expect port 80 to do HTTPS, so a HTTP redirect using Apache or node.js is at least going to be more conventional.

In answer to your direct question about iptables forwarding though, instead of your REDIRECT, you can see what happens if you try

iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 54.207.73.169:443 

(or whatever IP address you want to use. Localhost should be fine if the server is bound to it.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .