Find the answer to your Linux question:
Results 1 to 3 of 3
Hi I have a small problem. My Apache is configured in this way that I have one IP and more VirtualHost Something like this: Code: NameVirtualHost 123.456.7.89 .. <VirtualHost subdomain.site.com ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2005
    Posts
    6

    [SOLVED] Apache with and without SSL == Site with https and http


    Hi

    I have a small problem.
    My Apache is configured in this way that I have one IP and more VirtualHost

    Something like this:
    Code:
    NameVirtualHost 123.456.7.89
    ..
    <VirtualHost subdomain.site.com >
    ....
    </VirtualHost>
    
    <VirtualHost subdomain2.site.com>
    </VirtualHost>
    
    <VirtualHost subdomain.othersite.com>
    ...
    </VirtualHost>
    Now I need to have one site with SSL Encryption.
    So I tried something like this
    Code:
    NameVirtualHost 123.456.7.89
    ..
    <VirtualHost subdomain.site.com >
          ServerName subdomain.site.com
    </VirtualHost>
    
    <VirtualHost subdomain.othersite.com>
    ...
    </VirtualHost>   
    
    <VirtualHost subdomain.site.com >
          ServerName subdomain.site.com:443
          SSLCertificateFile /etc/httpd/ssl/cert.crt
          SSLCertificateKeyFile /etc/httpd/ssl/cert.key    
          SSLEngine on
    ......
    </VirtualHost>
    In this way the subdomain.site.com was accessible via https and all sites returning 400 - bad request when I tried to access it via http.

    I read a bit and found out that the SSL encrypted site have to have own IP address. So I ordered new IP and tried this:

    DNS-Entry shows subdomain.site.com on IP 123.456.7.900

    Code:
    NameVirtualHost 123.456.7.89
    ..
    <VirtualHost subdomain.site.com >
          ServerName subdomain.site.com
    </VirtualHost>
    
    <VirtualHost subdomain.othersite.com>
    ...
    </VirtualHost>   
    
    <VirtualHost 123.456.7.900 >
          ServerName subdomain.site.com:443
          SSLCertificateFile /etc/httpd/ssl/cert.crt
          SSLCertificateKeyFile /etc/httpd/ssl/cert.key    
          SSLEngine on
    ......
    </VirtualHost>
    Now are all other site ok again (accessible via HTTP).
    But the site I need to secure subdomain.site.com is accessible via https.
    If I try to access it with http I get 400 - bad request.

    What I need to do is to have:
    - Several named based VirtualHost without encryption
    - One or more sites with SSL encryption
    - One or more sites accessible with and without SSL encryption
    - I have 5 IP addresses available for it.

    It is possible?

    Kind regards,
    Neo

  2. #2
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    Quote Originally Posted by neo_fox View Post
    Hi

    It is possible?
    Yes

    I assume you have already changed it to listen on 443.

    how about this
    Code:
    NameVirtualHost 123.456.7.89:80
    NameVirtualHost 123.456.7.89:443
    ..
    <VirtualHost subdomain.site.com:80 >
    ....
    </VirtualHost>
    
    <VirtualHost subdomain2.site.com:80>
    </VirtualHost>
    
    <VirtualHost subdomain.othersite.com:443>
    Your ssl stuff here.  and did you create the ssl
    </VirtualHost>
    restart apache and then do a
    #tail -f /../../apache/error.log

    and then try and access your ssl site and see what gets logged.

  3. #3
    Just Joined!
    Join Date
    Nov 2005
    Posts
    6
    You have fully right this was exactly this problem.
    It is neccessary to tell Apache to listing both ports for this IP and then the port has to be also defined in the VirtualHost name.

    Thanks,
    Neo

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •