Knowledge Base

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I redirect HTTP requests to HTTPS on Linux?

Users can redirect requests from HTTP to the HTTPS Controller port on Linux using Iptables.

 

  1. In your computer terminal, replace eth0 with your actual interface name using the following command:
    • sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport <HTTP_PORT> -j REDIRECT --to-port <HTTPS_PORT>
  2. If port 8090 and 8181 are not open, run the following command:
    • sudo iptables -A INPUT -i eth0 -p tcp --dport <HTTP_PORT> -j ACCEPT
Example:

 

Note: Assuming interface "eth0," HTTP port "8090," and HTTPS port "8181."

 

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 8090 -j REDIRECT --to-port 8181
sudo iptables -A INPUT -i eth0 -p tcp --dport 8090 -j ACCEPT

 

Version history
Revision #:
3 of 3
Last update:
‎12-30-2018 11:01 AM
Updated by:
 
0 Kudos