Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Hudson/Jenkins installation which runs on port 443, so I can access it with I do not have a webserver running on port 80 like Apache Httpd, but I want if a user types 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
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 to

share|improve this question

marked as duplicate by Katherine Villyard, mdpc, Avery Payne, Falcon Momot, dawud Feb 15 '14 at 11:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Okay I have to install sth. like Apache. And then, what is the best way to redirect? – Tim Jun 8 '11 at 15:59

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.

share|improve this answer

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.

share|improve this answer

Setup a relatively blank VirtualHost listening on 80, which does nothing but

RewriteEngine On

RewriteRule (.*)$1

share|improve this answer

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.

share|improve this answer

You are probably at an impasse here as http & https are dissimilar enough where a simple port redirect is not going to work.

share|improve this answer

If this is a follow-up of this question, the problem is that you're trying to run Jenkins on a privileged port (<1024). You're mixing things up with port 80 and 443 in your question here.

Run Jenkins on port 8443 (which is usual for an unprivileged HTTPS port) and use iptables to redirect from/to 443 and 8443.

To redirect from http:// to https://, Apache and mod_rewrite is a good choice, as others have suggested. Alternatively, any tiny web server should be able to send a redirect (HTTP 301 or 302 status) with a Location header.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.