-1

I've setup a redirect for capturing all http: (port 80) traffic. This is to resolve a security issue (ie. don't allow anyone direct access to the server).

<VirtualHost *:80>
    DocumentRoot "/var/www/html/redirect"
</VirtualHost>

This is the first entry in the vhosts file and works fine. However, I'd like to also use this for all redirecting all https: traffic (port 443) using the following (place directly after the first entry in the vhost file...

<VirtualHost *:443>
    DocumentRoot "/var/www/html/redirect"
</VirtualHost>

However, doing this crashes all our sites....

I've ran an httpd -S and it returns no errors.

Any advice on how to setup the https redirect?

Adam Harkus
  • 2,050
  • 2
  • 36
  • 64
  • Is your server listening port 443 ? – Goufalite Feb 23 '17 at 12:59
  • 1. I have no idea why specifying such a `DocumentRoot` should "redirect" any access or some something else... and 2. you certainly can make your http server listen on port 443, but you do not specify any configuration for the certificate handling which is required for the https protocol which is normally used on port 443... This _mighty_ just be a drastically reduced configuration you posted, but we cannot know that. But most important: 3. what does your http servers error log file reveal when you restart it? – arkascha Feb 23 '17 at 13:01
  • That s the exact config, although there's many other entries folllowing those 2. I'd rather not be tinkering and checking out error logs right now as any errors bring down the live sites – Adam Harkus Feb 23 '17 at 13:16

1 Answers1

0

According to this answer, you need to specify SSL for the :443 virtualhost

<VirtualHost *:443>
    SSLEngine On
    DocumentRoot "/var/www/html/redirect"
</VirtualHost>

Also look in your site configuration if your server is listening to 443. Check your error logs at runtime while accessing the page.

Community
  • 1
  • 1
Goufalite
  • 2,253
  • 3
  • 17
  • 29
  • Please note, var/www/html/redirect is just a folder with no particular SSL associated with it.. Like I say, it work for *:80. – Adam Harkus Feb 23 '17 at 13:14
  • It will work without `SSLEngine On` provided you do not use SSL to browse, I would say that the OP is trying to hit 443 with SSL and Apache is bugging out for some reason. Also make sure you have `Listen 443` set somewhere. – Geoffrey Feb 23 '17 at 13:30
  • Could you please give an example? – Adam Harkus Feb 23 '17 at 15:41