AppDynamics Knowledge Base

How do I redirect HTTP requests to HTTPS on Linux?

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
Last update:
‎05-31-2017 11:17 AM
Updated by: