[Apache] Redirect HTTP naar HTTPS gaat niet goed

Pagina: 1
Acties:

Vraag


Acties:
  • 0 Henk 'm!

  • tHe_BiNk
  • Registratie: September 2001
  • Niet online

tHe_BiNk

He's evil! Very EVIL!

Topicstarter
Ubuntu server 14.04.5 up to date, Apache, TransIP VPS

Ik ben voor het eerst bezig om onze websites van HTTP naar HTTPS om te zetten. Ik heb de benodigde certificaten en deze werken goed.

De www.example.nl.conf bestanden zijn/waren voor de HTTP websites als volgt;

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#  example.nl (/etc/apache2/sites-available/www.example.nl)
#
<VirtualHost *>
        ServerAdmin websites@example.nl
        ServerName  www.example.nl
        ServerAlias example.nl

        # Indexes + Directory Root.
        DirectoryIndex index.php
        DocumentRoot /home/www/www.example.nl/htdocs/

        # CGI Directory
        Alias /awstatsclasses "/usr/share/awstats/lib/"
        Alias /awstats-icon/ "/usr/share/awstats/icon/"
        Alias /awstatscss "/usr/share/doc/awstats/examples/css"
        ScriptAlias /awstats/ /usr/lib/cgi-bin/
        ScriptAlias /cgi-bin/ /home/www/www.example.nl/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>


        # Logfiles
        ErrorLog  /home/www/www.example.nl/logs/error.log
        CustomLog /home/www/www.example.nl/logs/access.log combined
</VirtualHost>


Nu moet ik al het HTTP traffic naar HTTPS sturen en dan heb ik het dus zo

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#NameVirtualHost *:80
#<VirtualHost *:80>
#       ServerName example.nl
#       ServerAlias www.example.nl
#       DocumentRoot /home/www/www.example.nl/htdocs/
#       Redirect permanent / https://example.nl/
#</VirtualHost>

<VirtualHost *:443>
ServerAdmin websites@example.nl
ServerName example.nl
ServerAlias www.example.nl

        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/example.crt
        SSLCertificateKeyFile /etc/apache2/ssl/example.key
        SSLCACertificateFile /etc/apache2/ssl/examplecabundle.crt

        # Indexes + Directory Root.
        DirectoryIndex index.php
        DocumentRoot /home/www/www.example.nl/htdocs/

        # CGI Directory
        Alias /awstatsclasses "/usr/share/awstats/lib/"
        Alias /awstats-icon/ "/usr/share/awstats/icon/"
        Alias /awstatscss "/usr/share/doc/awstats/examples/css"
        ScriptAlias /awstats/ /usr/lib/cgi-bin/
        ScriptAlias /cgi-bin/ /home/www/www.example.nl/cgi-bin/

        <Location /cgi-bin>
                Options +ExecCGI
        </Location>



        # Logfiles
        ErrorLog  /home/www/www.example.nl/logs/error.log
        CustomLog /home/www/www.example.nl/logs/access.log combined
</VirtualHost>


Dan werkt het allemaal goed. MAAR dan worden ALLE andere websites "example2.nl, example3.nl" etc., ook doorgestuurd (die nog gewoon HTTP zijn en pas straks/niet worden omgezet) naar https://example.nl.

Als ik de onderstaande code weghaal dan is dit niet meer het geval. Echter dan werkt de doorverwijzing van http://example naar https://example niet meer.

code:
1
2
3
4
5
6
7
#NameVirtualHost *:80
#<VirtualHost *:80>
#       ServerName example.nl
#       ServerAlias www.example.nl
#       DocumentRoot /home/www/www.example.nl/htdocs/
#       Redirect permanent / https://example.nl/
#</VirtualHost>



Het probleem zit waarschijnlijk in de code hierboven. Wat doe ik niet goed?

APPLYitYourself.co.uk - APPLYitYourself.com - PLAKhetzelf.nl - Raamfolie, muurstickers en stickers - WindowDeco.nl Raamfolie op maat.

Beste antwoord (via Hero of Time op 16-09-2016 18:46)


  • tHe_BiNk
  • Registratie: September 2001
  • Niet online

tHe_BiNk

He's evil! Very EVIL!

Topicstarter
Volgens mij was ik vannacht niet al te wakker. Paste net wat aan. En nu werkt het volgens mij perfect.

<VirtualHost *:80> -> <VirtualHost example.nl:80>

<VirtualHost *:443> -> <VirtualHost example.nl:443>

APPLYitYourself.co.uk - APPLYitYourself.com - PLAKhetzelf.nl - Raamfolie, muurstickers en stickers - WindowDeco.nl Raamfolie op maat.

Alle reacties


Acties:
  • Beste antwoord
  • 0 Henk 'm!

  • tHe_BiNk
  • Registratie: September 2001
  • Niet online

tHe_BiNk

He's evil! Very EVIL!

Topicstarter
Volgens mij was ik vannacht niet al te wakker. Paste net wat aan. En nu werkt het volgens mij perfect.

<VirtualHost *:80> -> <VirtualHost example.nl:80>

<VirtualHost *:443> -> <VirtualHost example.nl:443>

APPLYitYourself.co.uk - APPLYitYourself.com - PLAKhetzelf.nl - Raamfolie, muurstickers en stickers - WindowDeco.nl Raamfolie op maat.


Acties:
  • 0 Henk 'm!

  • Hero of Time
  • Registratie: Oktober 2004
  • Laatst online: 01-10 21:30

Hero of Time

Moderator LNX

There is only one Legend

Als je een redirect doet, moet je dat met regexp afvangen. Wat je nu hebt, verwijst alleen het hoofd domein, niet example.nl/pagina/hoi.html.

Altijd twee vhosts, een voor de redirect die heel simpel is en de ander voor je site zelf met alles erin.

Commandline FTW | Tweakt met mate


Acties:
  • 0 Henk 'm!

  • tHe_BiNk
  • Registratie: September 2001
  • Niet online

tHe_BiNk

He's evil! Very EVIL!

Topicstarter
Thanks.

Solved.

APPLYitYourself.co.uk - APPLYitYourself.com - PLAKhetzelf.nl - Raamfolie, muurstickers en stickers - WindowDeco.nl Raamfolie op maat.