Apache 2 with SSL virtual host on different port 8080 or 8081 in Linux

17,846
Listen 443
Listen 8081
Listen 8082

<VirtualHost 127.0.0.1:8081>
    ServerName Test.domain.com
    SSLProxyEngine on
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/server.crt
    SSLCertificateKeyFile /etc/ssl/private/server.key
    DocumentRoot /var/www/html/test/
</VirtualHost>

<VirtualHost 127.0.0.1:8082>
    ServerName Test.domain.com
    SSLProxyEngine on
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/server.crt
    SSLCertificateKeyFile /etc/ssl/private/server.key
    DocumentRoot /var/www/html/test2/
</VirtualHost>

Please refer to more examples for VirtualHost: https://httpd.apache.org/docs/2.4/vhosts/examples.html

Share:
17,846
Admin
Author by

Admin

Updated on December 01, 2022

Comments

  • Admin
    Admin 11 months

    I was trying to configure SSL(443) for one of the virtual hosts configured in Linux with same domain name with diffrent port number I have used mod_ssl for the configuring the https. For virtual hosts 80 with https it is working fine.Now the problem is I have configured another virtalhosts on port number 8081 and 8082 and I want to provide the HTTPS for both 8081 and 8082 configured Virtuals Hosts.

    Sites with port number 8081 and 8082 are working but I need those ports has to work with https

    Can anyone please help me on this

    I have tried below configuration:

    <VirtualHost *:443 *8081>
        ServerName Test.domain.com
        SSLProxyEngine on
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key
        DocumentRoot /var/www/html/test/
    </VirtualHost>
    
    <VirtualHost *:443 *8082>
        ServerName Test.domain.com
        SSLProxyEngine on
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key
        DocumentRoot /var/www/html/test2/
    </VirtualHost>