How would I go about setting up a SSL reverse proxy using apache as the ssl reverse proxy and lighttpd as the web server?

I want everyone to be forced to connect with ssl, so any http connections get redirected to https. I want the web server running on 8080 to only accept connections from (ie the proxy server) I want my application on port 23424 to be accessible using a /example rather than :23424/example.

What would be the best way of going about this?

On ubuntu12.04 lts

  • Would it be better to use nginx as the reverse ssl proxy and apache as the server? I want to run things like phpmyadmin too – JonnyV Feb 20 '14 at 21:16
  • I run a similar server redirecting http to https (html redirect via index.html) except for local trafic which goes to a different virtual host. This way you don't need a proxy and you can do everything with apache. Not an answer to your question but maybe a solution to your problem? – Requist Feb 20 '14 at 22:16
  • Yes I hadn't thought of it like that. It might just work. Do you have any links I can read that would give me an idea how to do this? – JonnyV Feb 22 '14 at 11:13

A different approach but with almost the same effect is to use Apache with different virtual hosts and html redirect (optional with htaccess for extra security).

The difference in end result will be that you can not deep-link a http request to https, so people accessing http://www.example.org will be redirected to https://www.example.org, but people who try to access http://www.example.org/existing/link.html will get a 404 page not found error. Once entered through http they will just continue server via https, so this is only an issue for existing links or people typing their own links (and forget https).

Maybe this could be achieved with the mod rewrite but I have not tested this so I am not sure if it is possible to do the redirect to a different port.

The setup would look like this:

Virtual host 1: is default server and listens to port 443
This host will consist of the main external webpages.

To setup virtual hosts, see

Virtual host 2: listens to port 80 to the name http://externaldomainname.org 
with an optional alias http://www.externaldomainname.org
In the root of this virtual host only one file exist, a html redirect. 

To do html redirecting, see

Virtual host 3: listens to port 80 to a local name (localhost or hostname)
will only be accessible from localhost for local applications.
if real security is required, access should be limited by use of htaccess.

To limit access through htaccess, see

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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