I am using this apache configuration to set up a reverse proxy to a process running on the same machine, on port 8443,

<Directory "/var/www/html">
   Options +FollowSymLinks
   RewriteEngine On
   RewriteCond %{HTTPS} off 
   RewriteRule ^(.*) https://%{HTTP_HOST}/$1

<IfModule mod_proxy.c>

ProxyRequests Off

<Proxy *>
   Order deny,allow
   Allow from all

SSLProxyEngine On
ProxyPass /
ProxyPassReverse /


The process running on 8443 already has HTTPS / SSL certificate set up. Is this a valid / good configuration or can I do it better?

I noticed that currently even http:// will proxy to https:// without the rewrite kicking in. I think this might compromise SSL? I'd rather have only 443 proxy to 8443 and just use a URL rewrite to rewrite the http:// requests to https:// requests. Is that possible using apache?


EDIT - Here is the virtual host information as requested,

VirtualHost Configuration: 
wildcard NameVirtualHosts and _default_ servers:
_default_:443 (/etc/httpd/conf.d/ssl.conf:74)
Syntax OK
  • Sounds like this is just in the global config and not in a <VirtualHost> block, right? Can you add the output from apachectl -S to your question? – Shane Madden Jul 5 '14 at 18:01
  • See my edit. This is global configuration in httpd.conf. – Sean Thoman Jul 5 '14 at 18:24

To get the HTTP requests to redirect instead of proxying, you should do two things:

  1. Move your proxying config (SSLProxyEngine through ProxyPassReverse into the SSL virtual host in /etc/httpd/conf.d/ssl.conf, so that it'll only apply there

  2. Create an HTTP virtual host which will redirect - probably in a new .conf file in /etc/httpd/conf.d:

    <VirtualHost *:80>
      ServerName redirect
      RewriteEngine On
      RewriteRule ^(.*) https://%{HTTP_HOST}/$1

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.