https redirect to virtual host directory and http not working











up vote
0
down vote

favorite












System configuration




  1. ubuntu14.04 (64bit)

  2. XAMPP 1.8.3-5


    • Apache/2.4.10
      (Unix) OpenSSL/1.0.1i PHP/5.5.15 mod_perl/2.0.8-dev Perl/v5.16.3




I have read on new features of apache 2.4




NameVirtualHost directive

No longer needed and is now deprecated.




So instead of NameVirtual hostI tried other ip-based virtual hosts.



Below changes I have made to work with



httpd.conf



uncommented Include line inside <IfModule ssl_module> block



<IfModule ssl_module>
<IfDefine SSL>
Include etc/extra/httpd-ssl.conf
</IfDefine>
</IfModule>


httpd-ssl.conf



create apache ssl certificate and add log files on respective location



<VirtualHost localhost:443>

DocumentRoot "/opt/lampp/htdocs/wsdl"
ServerName wsdl.local
ServerAlias wsdl.local
ServerAdmin myemail@email.com
ErrorLog "/opt/lampp/logs/wsdl_error_log"
TransferLog "/opt/lampp/logs/wsdl_access_log"
SSLEngine on
SSLCertificateFile "/opt/lampp/apache2/ssl/wsdl.crt"
SSLCertificateKeyFile "/opt/lampp/apache2/ssl/wsdl.key"
</VirtualHost>


here is the error log file



wsdl_error_log



[Fri Nov 21 15:43:12.001231 2014] [ssl:warn] [pid 5322] AH01906: wsdl.local:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Nov 21 15:43:12.001350 2014] [ssl:warn] [pid 5322] AH01909: wsdl.local:443:0 server certificate does NOT include an ID which matches the server name
[Fri Nov 21 15:43:13.001886 2014] [ssl:warn] [pid 5323] AH01906: wsdl.local:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Nov 21 15:43:13.001960 2014] [ssl:warn] [pid 5323] AH01909: wsdl.local:443:0 server certificate does NOT include an ID which matches the server name


My problem is





  • http://localhost >> Bad request


  • https://localhost/wsdl/ >> not working


  • https://192.168.xx.xx/ >> Secure Connection Failed (Error code: ssl_error_rx_record_too_long)


  • https://192.168.xx.xx/wsdl/ >> SSL connection Error


while





  • http://192.168.xx.xx/ >> working (just like the defualt xammpp)


  • http://localhost navigate to http://localhost/wsdl directory


P.S localhost behaves same as 127.0.0.1 in each condition



Please suggest What something extra I have to add to make it workful? like




  • adding something on /etc/hosts or any other configuration
    or

  • um commenting Include etc/extra/httpd-vhosts.conf in httpd.conf




update



created proper certificate
Note: write wsdl.local




The most important item that is requested is the line that reads
"Common Name (e.g. server FQDN or YOUR name)". You should enter the
domain name you want to associate with the certificate, or the
server's public IP address if you do not have a domain name.




added virtual host address in /etc/hosts



127.0.0.1 wsdl.local


altered /opt/lampp/etc/extra/ httpd-ssl.conf



<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost _default_:443> <-- added back _default_
ServerAlias www.wsdl.local <-- alias append with www

<Directory "/opt/lampp/htdocs/wsdl"> <-- wraped directory in "
Options All
AllowOverride All
order allow,deny
allow from all
#SSLRequireSSL <-- commented
</Directory>


and I notice changes in URL behavior




  • http://wsdl.local/ http://localhost & http://127.0.0.1 >> URL changed to http://wsdl.local/xampp/ and display XAMPP main page


  • https://wsdl.local/ & https://localhost/ navigated to wsdl directory (which is desired )


  • https://127.0.0.1/ >> URl turns into https://127.0.0.1/xampp/ and Object not found



But this is still not expected, what require is




http[s]://localhost/ and http[s]://127.0.0.1/ take me to XAMPP main page



http[s]://wsdl.local would navigated to wsdl directory











share|improve this question
























  • Um.. localhost not working? Try pgrep "apache" if apache is running, netstat -patn see if it is listening on port 80. Its possible that you have specified 192 address as the listening address. You can change this to 0.0.0.0 - this will allow for the server to listen on all IP addresses. If http is working but https is not working - check if port is listening, if not - configure the service to listen on 443.
    – mnmnc
    Nov 21 '14 at 11:01












  • /opt/lampp/lampp status >> apache working
    – diEcho
    Nov 21 '14 at 11:04










  • netstat -patn tcp6 0 0 :::443 :::* LISTEN
    – diEcho
    Nov 21 '14 at 11:15















up vote
0
down vote

favorite












System configuration




  1. ubuntu14.04 (64bit)

  2. XAMPP 1.8.3-5


    • Apache/2.4.10
      (Unix) OpenSSL/1.0.1i PHP/5.5.15 mod_perl/2.0.8-dev Perl/v5.16.3




I have read on new features of apache 2.4




NameVirtualHost directive

No longer needed and is now deprecated.




So instead of NameVirtual hostI tried other ip-based virtual hosts.



Below changes I have made to work with



httpd.conf



uncommented Include line inside <IfModule ssl_module> block



<IfModule ssl_module>
<IfDefine SSL>
Include etc/extra/httpd-ssl.conf
</IfDefine>
</IfModule>


httpd-ssl.conf



create apache ssl certificate and add log files on respective location



<VirtualHost localhost:443>

DocumentRoot "/opt/lampp/htdocs/wsdl"
ServerName wsdl.local
ServerAlias wsdl.local
ServerAdmin myemail@email.com
ErrorLog "/opt/lampp/logs/wsdl_error_log"
TransferLog "/opt/lampp/logs/wsdl_access_log"
SSLEngine on
SSLCertificateFile "/opt/lampp/apache2/ssl/wsdl.crt"
SSLCertificateKeyFile "/opt/lampp/apache2/ssl/wsdl.key"
</VirtualHost>


here is the error log file



wsdl_error_log



[Fri Nov 21 15:43:12.001231 2014] [ssl:warn] [pid 5322] AH01906: wsdl.local:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Nov 21 15:43:12.001350 2014] [ssl:warn] [pid 5322] AH01909: wsdl.local:443:0 server certificate does NOT include an ID which matches the server name
[Fri Nov 21 15:43:13.001886 2014] [ssl:warn] [pid 5323] AH01906: wsdl.local:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Nov 21 15:43:13.001960 2014] [ssl:warn] [pid 5323] AH01909: wsdl.local:443:0 server certificate does NOT include an ID which matches the server name


My problem is





  • http://localhost >> Bad request


  • https://localhost/wsdl/ >> not working


  • https://192.168.xx.xx/ >> Secure Connection Failed (Error code: ssl_error_rx_record_too_long)


  • https://192.168.xx.xx/wsdl/ >> SSL connection Error


while





  • http://192.168.xx.xx/ >> working (just like the defualt xammpp)


  • http://localhost navigate to http://localhost/wsdl directory


P.S localhost behaves same as 127.0.0.1 in each condition



Please suggest What something extra I have to add to make it workful? like




  • adding something on /etc/hosts or any other configuration
    or

  • um commenting Include etc/extra/httpd-vhosts.conf in httpd.conf




update



created proper certificate
Note: write wsdl.local




The most important item that is requested is the line that reads
"Common Name (e.g. server FQDN or YOUR name)". You should enter the
domain name you want to associate with the certificate, or the
server's public IP address if you do not have a domain name.




added virtual host address in /etc/hosts



127.0.0.1 wsdl.local


altered /opt/lampp/etc/extra/ httpd-ssl.conf



<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost _default_:443> <-- added back _default_
ServerAlias www.wsdl.local <-- alias append with www

<Directory "/opt/lampp/htdocs/wsdl"> <-- wraped directory in "
Options All
AllowOverride All
order allow,deny
allow from all
#SSLRequireSSL <-- commented
</Directory>


and I notice changes in URL behavior




  • http://wsdl.local/ http://localhost & http://127.0.0.1 >> URL changed to http://wsdl.local/xampp/ and display XAMPP main page


  • https://wsdl.local/ & https://localhost/ navigated to wsdl directory (which is desired )


  • https://127.0.0.1/ >> URl turns into https://127.0.0.1/xampp/ and Object not found



But this is still not expected, what require is




http[s]://localhost/ and http[s]://127.0.0.1/ take me to XAMPP main page



http[s]://wsdl.local would navigated to wsdl directory











share|improve this question
























  • Um.. localhost not working? Try pgrep "apache" if apache is running, netstat -patn see if it is listening on port 80. Its possible that you have specified 192 address as the listening address. You can change this to 0.0.0.0 - this will allow for the server to listen on all IP addresses. If http is working but https is not working - check if port is listening, if not - configure the service to listen on 443.
    – mnmnc
    Nov 21 '14 at 11:01












  • /opt/lampp/lampp status >> apache working
    – diEcho
    Nov 21 '14 at 11:04










  • netstat -patn tcp6 0 0 :::443 :::* LISTEN
    – diEcho
    Nov 21 '14 at 11:15













up vote
0
down vote

favorite









up vote
0
down vote

favorite











System configuration




  1. ubuntu14.04 (64bit)

  2. XAMPP 1.8.3-5


    • Apache/2.4.10
      (Unix) OpenSSL/1.0.1i PHP/5.5.15 mod_perl/2.0.8-dev Perl/v5.16.3




I have read on new features of apache 2.4




NameVirtualHost directive

No longer needed and is now deprecated.




So instead of NameVirtual hostI tried other ip-based virtual hosts.



Below changes I have made to work with



httpd.conf



uncommented Include line inside <IfModule ssl_module> block



<IfModule ssl_module>
<IfDefine SSL>
Include etc/extra/httpd-ssl.conf
</IfDefine>
</IfModule>


httpd-ssl.conf



create apache ssl certificate and add log files on respective location



<VirtualHost localhost:443>

DocumentRoot "/opt/lampp/htdocs/wsdl"
ServerName wsdl.local
ServerAlias wsdl.local
ServerAdmin myemail@email.com
ErrorLog "/opt/lampp/logs/wsdl_error_log"
TransferLog "/opt/lampp/logs/wsdl_access_log"
SSLEngine on
SSLCertificateFile "/opt/lampp/apache2/ssl/wsdl.crt"
SSLCertificateKeyFile "/opt/lampp/apache2/ssl/wsdl.key"
</VirtualHost>


here is the error log file



wsdl_error_log



[Fri Nov 21 15:43:12.001231 2014] [ssl:warn] [pid 5322] AH01906: wsdl.local:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Nov 21 15:43:12.001350 2014] [ssl:warn] [pid 5322] AH01909: wsdl.local:443:0 server certificate does NOT include an ID which matches the server name
[Fri Nov 21 15:43:13.001886 2014] [ssl:warn] [pid 5323] AH01906: wsdl.local:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Nov 21 15:43:13.001960 2014] [ssl:warn] [pid 5323] AH01909: wsdl.local:443:0 server certificate does NOT include an ID which matches the server name


My problem is





  • http://localhost >> Bad request


  • https://localhost/wsdl/ >> not working


  • https://192.168.xx.xx/ >> Secure Connection Failed (Error code: ssl_error_rx_record_too_long)


  • https://192.168.xx.xx/wsdl/ >> SSL connection Error


while





  • http://192.168.xx.xx/ >> working (just like the defualt xammpp)


  • http://localhost navigate to http://localhost/wsdl directory


P.S localhost behaves same as 127.0.0.1 in each condition



Please suggest What something extra I have to add to make it workful? like




  • adding something on /etc/hosts or any other configuration
    or

  • um commenting Include etc/extra/httpd-vhosts.conf in httpd.conf




update



created proper certificate
Note: write wsdl.local




The most important item that is requested is the line that reads
"Common Name (e.g. server FQDN or YOUR name)". You should enter the
domain name you want to associate with the certificate, or the
server's public IP address if you do not have a domain name.




added virtual host address in /etc/hosts



127.0.0.1 wsdl.local


altered /opt/lampp/etc/extra/ httpd-ssl.conf



<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost _default_:443> <-- added back _default_
ServerAlias www.wsdl.local <-- alias append with www

<Directory "/opt/lampp/htdocs/wsdl"> <-- wraped directory in "
Options All
AllowOverride All
order allow,deny
allow from all
#SSLRequireSSL <-- commented
</Directory>


and I notice changes in URL behavior




  • http://wsdl.local/ http://localhost & http://127.0.0.1 >> URL changed to http://wsdl.local/xampp/ and display XAMPP main page


  • https://wsdl.local/ & https://localhost/ navigated to wsdl directory (which is desired )


  • https://127.0.0.1/ >> URl turns into https://127.0.0.1/xampp/ and Object not found



But this is still not expected, what require is




http[s]://localhost/ and http[s]://127.0.0.1/ take me to XAMPP main page



http[s]://wsdl.local would navigated to wsdl directory











share|improve this question















System configuration




  1. ubuntu14.04 (64bit)

  2. XAMPP 1.8.3-5


    • Apache/2.4.10
      (Unix) OpenSSL/1.0.1i PHP/5.5.15 mod_perl/2.0.8-dev Perl/v5.16.3




I have read on new features of apache 2.4




NameVirtualHost directive

No longer needed and is now deprecated.




So instead of NameVirtual hostI tried other ip-based virtual hosts.



Below changes I have made to work with



httpd.conf



uncommented Include line inside <IfModule ssl_module> block



<IfModule ssl_module>
<IfDefine SSL>
Include etc/extra/httpd-ssl.conf
</IfDefine>
</IfModule>


httpd-ssl.conf



create apache ssl certificate and add log files on respective location



<VirtualHost localhost:443>

DocumentRoot "/opt/lampp/htdocs/wsdl"
ServerName wsdl.local
ServerAlias wsdl.local
ServerAdmin myemail@email.com
ErrorLog "/opt/lampp/logs/wsdl_error_log"
TransferLog "/opt/lampp/logs/wsdl_access_log"
SSLEngine on
SSLCertificateFile "/opt/lampp/apache2/ssl/wsdl.crt"
SSLCertificateKeyFile "/opt/lampp/apache2/ssl/wsdl.key"
</VirtualHost>


here is the error log file



wsdl_error_log



[Fri Nov 21 15:43:12.001231 2014] [ssl:warn] [pid 5322] AH01906: wsdl.local:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Nov 21 15:43:12.001350 2014] [ssl:warn] [pid 5322] AH01909: wsdl.local:443:0 server certificate does NOT include an ID which matches the server name
[Fri Nov 21 15:43:13.001886 2014] [ssl:warn] [pid 5323] AH01906: wsdl.local:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Nov 21 15:43:13.001960 2014] [ssl:warn] [pid 5323] AH01909: wsdl.local:443:0 server certificate does NOT include an ID which matches the server name


My problem is





  • http://localhost >> Bad request


  • https://localhost/wsdl/ >> not working


  • https://192.168.xx.xx/ >> Secure Connection Failed (Error code: ssl_error_rx_record_too_long)


  • https://192.168.xx.xx/wsdl/ >> SSL connection Error


while





  • http://192.168.xx.xx/ >> working (just like the defualt xammpp)


  • http://localhost navigate to http://localhost/wsdl directory


P.S localhost behaves same as 127.0.0.1 in each condition



Please suggest What something extra I have to add to make it workful? like




  • adding something on /etc/hosts or any other configuration
    or

  • um commenting Include etc/extra/httpd-vhosts.conf in httpd.conf




update



created proper certificate
Note: write wsdl.local




The most important item that is requested is the line that reads
"Common Name (e.g. server FQDN or YOUR name)". You should enter the
domain name you want to associate with the certificate, or the
server's public IP address if you do not have a domain name.




added virtual host address in /etc/hosts



127.0.0.1 wsdl.local


altered /opt/lampp/etc/extra/ httpd-ssl.conf



<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost _default_:443> <-- added back _default_
ServerAlias www.wsdl.local <-- alias append with www

<Directory "/opt/lampp/htdocs/wsdl"> <-- wraped directory in "
Options All
AllowOverride All
order allow,deny
allow from all
#SSLRequireSSL <-- commented
</Directory>


and I notice changes in URL behavior




  • http://wsdl.local/ http://localhost & http://127.0.0.1 >> URL changed to http://wsdl.local/xampp/ and display XAMPP main page


  • https://wsdl.local/ & https://localhost/ navigated to wsdl directory (which is desired )


  • https://127.0.0.1/ >> URl turns into https://127.0.0.1/xampp/ and Object not found



But this is still not expected, what require is




http[s]://localhost/ and http[s]://127.0.0.1/ take me to XAMPP main page



http[s]://wsdl.local would navigated to wsdl directory








ubuntu apache-http-server ssl






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '14 at 13:26

























asked Nov 21 '14 at 10:39









diEcho

1591314




1591314












  • Um.. localhost not working? Try pgrep "apache" if apache is running, netstat -patn see if it is listening on port 80. Its possible that you have specified 192 address as the listening address. You can change this to 0.0.0.0 - this will allow for the server to listen on all IP addresses. If http is working but https is not working - check if port is listening, if not - configure the service to listen on 443.
    – mnmnc
    Nov 21 '14 at 11:01












  • /opt/lampp/lampp status >> apache working
    – diEcho
    Nov 21 '14 at 11:04










  • netstat -patn tcp6 0 0 :::443 :::* LISTEN
    – diEcho
    Nov 21 '14 at 11:15


















  • Um.. localhost not working? Try pgrep "apache" if apache is running, netstat -patn see if it is listening on port 80. Its possible that you have specified 192 address as the listening address. You can change this to 0.0.0.0 - this will allow for the server to listen on all IP addresses. If http is working but https is not working - check if port is listening, if not - configure the service to listen on 443.
    – mnmnc
    Nov 21 '14 at 11:01












  • /opt/lampp/lampp status >> apache working
    – diEcho
    Nov 21 '14 at 11:04










  • netstat -patn tcp6 0 0 :::443 :::* LISTEN
    – diEcho
    Nov 21 '14 at 11:15
















Um.. localhost not working? Try pgrep "apache" if apache is running, netstat -patn see if it is listening on port 80. Its possible that you have specified 192 address as the listening address. You can change this to 0.0.0.0 - this will allow for the server to listen on all IP addresses. If http is working but https is not working - check if port is listening, if not - configure the service to listen on 443.
– mnmnc
Nov 21 '14 at 11:01






Um.. localhost not working? Try pgrep "apache" if apache is running, netstat -patn see if it is listening on port 80. Its possible that you have specified 192 address as the listening address. You can change this to 0.0.0.0 - this will allow for the server to listen on all IP addresses. If http is working but https is not working - check if port is listening, if not - configure the service to listen on 443.
– mnmnc
Nov 21 '14 at 11:01














/opt/lampp/lampp status >> apache working
– diEcho
Nov 21 '14 at 11:04




/opt/lampp/lampp status >> apache working
– diEcho
Nov 21 '14 at 11:04












netstat -patn tcp6 0 0 :::443 :::* LISTEN
– diEcho
Nov 21 '14 at 11:15




netstat -patn tcp6 0 0 :::443 :::* LISTEN
– diEcho
Nov 21 '14 at 11:15










1 Answer
1






active

oldest

votes

















up vote
0
down vote














Step 1: Use OpenSSL to produce the keys that are used to secure your
site. These keys are used when encrypting and decrypting the traffic
to your secure site.




$openssl genrsa -out mydomain.key 1024



Step 2: Generate your own certificate .




 $ openssl req -new -key mydomain.key -x509 -out mydomain.crt



Step 3: Keep the pricate key in the directory /etc/apache2/ssl.key/
and certificate in the directory /etc/apache2/ssl.crt/.




Note: The ssl.key directory must be only readable by root.




Step 4: Now you need to edit httpd.conf file in /etc/apache2.




Now this file should include content like this:



> <VirtualHost *:80>
>
> ServerAdmin keshav.mohta@dotsquares.com
>
> DocumentRoot /opt/lampp/htdocs/wsdl
>
> ServerName www.mydomain.com
>
> ServerAlias mydomain.com
>
> </VirtualHost>


<VirtualHost *:443>

ServerAdmin keshav.mohta@dotsquares.com

DocumentRoot /opt/lampp/htdocs/wsdl

ServerName mail.mydomain.com

SSLEngine on

SSLCertificateFile /etc/apache2/ssl.crt/mydomain.crt

SSLCertificateKeyFile /etc/apache2/ssl.key/mydomain.key

ErrorLog "/opt/lampp/logs/wsdl_error_log"

TransferLog "/opt/lampp/logs/wsdl_access_log"

</VirtualHost>


<Directory /srv/www/htdocs/mydomain-secure>
SSLRequireSSL
</Directory>


Don't change Listen 80 to 443 in /etc/httpd/conf/httpd.conf. SSL is configured in /etc/httpd/conf.d/ssl.conf.
SSL is enabled and listening by default with a self signed certificate.



You can get to the default site using SSL just by browsing to https://localhost (you don't need to add the port to the end of the URL).



If you want to forward all HTTP requests to HTTPS (which is what I believe you are trying to achieve), you can either add a permanent redirect, or use the Apache module mod_rewrite.



The easiest and most secure way is to set up a permanent redirect. Enable named virtual hosts and add a Redirect directive to the VirtualHost in /etc/httpd/conf/httpd.conf.






share|improve this answer





















  • there is httpd-ssl.conf for the Virtual host configuration. Is that okay instead on httpd.conf
    – diEcho
    Nov 21 '14 at 11:51










  • I did whatever you have said but now it's block 192.168.xx.xx ( that was working earlier) now every request(localhost,192.xx or 127.0) goes to wsdl directory.
    – diEcho
    Nov 21 '14 at 11:59












  • I just want to run one site on https and rest are on http(like normal). that's all
    – diEcho
    Nov 21 '14 at 11:59












  • Note: Put generated key and certificate on opt/lampp/apache2/ssl folder with 664 permission
    – diEcho
    Nov 21 '14 at 12:26












  • I have updated my question Please see.
    – diEcho
    Nov 24 '14 at 9:53











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f843147%2fhttps-redirect-to-virtual-host-directory-and-http-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote














Step 1: Use OpenSSL to produce the keys that are used to secure your
site. These keys are used when encrypting and decrypting the traffic
to your secure site.




$openssl genrsa -out mydomain.key 1024



Step 2: Generate your own certificate .




 $ openssl req -new -key mydomain.key -x509 -out mydomain.crt



Step 3: Keep the pricate key in the directory /etc/apache2/ssl.key/
and certificate in the directory /etc/apache2/ssl.crt/.




Note: The ssl.key directory must be only readable by root.




Step 4: Now you need to edit httpd.conf file in /etc/apache2.




Now this file should include content like this:



> <VirtualHost *:80>
>
> ServerAdmin keshav.mohta@dotsquares.com
>
> DocumentRoot /opt/lampp/htdocs/wsdl
>
> ServerName www.mydomain.com
>
> ServerAlias mydomain.com
>
> </VirtualHost>


<VirtualHost *:443>

ServerAdmin keshav.mohta@dotsquares.com

DocumentRoot /opt/lampp/htdocs/wsdl

ServerName mail.mydomain.com

SSLEngine on

SSLCertificateFile /etc/apache2/ssl.crt/mydomain.crt

SSLCertificateKeyFile /etc/apache2/ssl.key/mydomain.key

ErrorLog "/opt/lampp/logs/wsdl_error_log"

TransferLog "/opt/lampp/logs/wsdl_access_log"

</VirtualHost>


<Directory /srv/www/htdocs/mydomain-secure>
SSLRequireSSL
</Directory>


Don't change Listen 80 to 443 in /etc/httpd/conf/httpd.conf. SSL is configured in /etc/httpd/conf.d/ssl.conf.
SSL is enabled and listening by default with a self signed certificate.



You can get to the default site using SSL just by browsing to https://localhost (you don't need to add the port to the end of the URL).



If you want to forward all HTTP requests to HTTPS (which is what I believe you are trying to achieve), you can either add a permanent redirect, or use the Apache module mod_rewrite.



The easiest and most secure way is to set up a permanent redirect. Enable named virtual hosts and add a Redirect directive to the VirtualHost in /etc/httpd/conf/httpd.conf.






share|improve this answer





















  • there is httpd-ssl.conf for the Virtual host configuration. Is that okay instead on httpd.conf
    – diEcho
    Nov 21 '14 at 11:51










  • I did whatever you have said but now it's block 192.168.xx.xx ( that was working earlier) now every request(localhost,192.xx or 127.0) goes to wsdl directory.
    – diEcho
    Nov 21 '14 at 11:59












  • I just want to run one site on https and rest are on http(like normal). that's all
    – diEcho
    Nov 21 '14 at 11:59












  • Note: Put generated key and certificate on opt/lampp/apache2/ssl folder with 664 permission
    – diEcho
    Nov 21 '14 at 12:26












  • I have updated my question Please see.
    – diEcho
    Nov 24 '14 at 9:53















up vote
0
down vote














Step 1: Use OpenSSL to produce the keys that are used to secure your
site. These keys are used when encrypting and decrypting the traffic
to your secure site.




$openssl genrsa -out mydomain.key 1024



Step 2: Generate your own certificate .




 $ openssl req -new -key mydomain.key -x509 -out mydomain.crt



Step 3: Keep the pricate key in the directory /etc/apache2/ssl.key/
and certificate in the directory /etc/apache2/ssl.crt/.




Note: The ssl.key directory must be only readable by root.




Step 4: Now you need to edit httpd.conf file in /etc/apache2.




Now this file should include content like this:



> <VirtualHost *:80>
>
> ServerAdmin keshav.mohta@dotsquares.com
>
> DocumentRoot /opt/lampp/htdocs/wsdl
>
> ServerName www.mydomain.com
>
> ServerAlias mydomain.com
>
> </VirtualHost>


<VirtualHost *:443>

ServerAdmin keshav.mohta@dotsquares.com

DocumentRoot /opt/lampp/htdocs/wsdl

ServerName mail.mydomain.com

SSLEngine on

SSLCertificateFile /etc/apache2/ssl.crt/mydomain.crt

SSLCertificateKeyFile /etc/apache2/ssl.key/mydomain.key

ErrorLog "/opt/lampp/logs/wsdl_error_log"

TransferLog "/opt/lampp/logs/wsdl_access_log"

</VirtualHost>


<Directory /srv/www/htdocs/mydomain-secure>
SSLRequireSSL
</Directory>


Don't change Listen 80 to 443 in /etc/httpd/conf/httpd.conf. SSL is configured in /etc/httpd/conf.d/ssl.conf.
SSL is enabled and listening by default with a self signed certificate.



You can get to the default site using SSL just by browsing to https://localhost (you don't need to add the port to the end of the URL).



If you want to forward all HTTP requests to HTTPS (which is what I believe you are trying to achieve), you can either add a permanent redirect, or use the Apache module mod_rewrite.



The easiest and most secure way is to set up a permanent redirect. Enable named virtual hosts and add a Redirect directive to the VirtualHost in /etc/httpd/conf/httpd.conf.






share|improve this answer





















  • there is httpd-ssl.conf for the Virtual host configuration. Is that okay instead on httpd.conf
    – diEcho
    Nov 21 '14 at 11:51










  • I did whatever you have said but now it's block 192.168.xx.xx ( that was working earlier) now every request(localhost,192.xx or 127.0) goes to wsdl directory.
    – diEcho
    Nov 21 '14 at 11:59












  • I just want to run one site on https and rest are on http(like normal). that's all
    – diEcho
    Nov 21 '14 at 11:59












  • Note: Put generated key and certificate on opt/lampp/apache2/ssl folder with 664 permission
    – diEcho
    Nov 21 '14 at 12:26












  • I have updated my question Please see.
    – diEcho
    Nov 24 '14 at 9:53













up vote
0
down vote










up vote
0
down vote










Step 1: Use OpenSSL to produce the keys that are used to secure your
site. These keys are used when encrypting and decrypting the traffic
to your secure site.




$openssl genrsa -out mydomain.key 1024



Step 2: Generate your own certificate .




 $ openssl req -new -key mydomain.key -x509 -out mydomain.crt



Step 3: Keep the pricate key in the directory /etc/apache2/ssl.key/
and certificate in the directory /etc/apache2/ssl.crt/.




Note: The ssl.key directory must be only readable by root.




Step 4: Now you need to edit httpd.conf file in /etc/apache2.




Now this file should include content like this:



> <VirtualHost *:80>
>
> ServerAdmin keshav.mohta@dotsquares.com
>
> DocumentRoot /opt/lampp/htdocs/wsdl
>
> ServerName www.mydomain.com
>
> ServerAlias mydomain.com
>
> </VirtualHost>


<VirtualHost *:443>

ServerAdmin keshav.mohta@dotsquares.com

DocumentRoot /opt/lampp/htdocs/wsdl

ServerName mail.mydomain.com

SSLEngine on

SSLCertificateFile /etc/apache2/ssl.crt/mydomain.crt

SSLCertificateKeyFile /etc/apache2/ssl.key/mydomain.key

ErrorLog "/opt/lampp/logs/wsdl_error_log"

TransferLog "/opt/lampp/logs/wsdl_access_log"

</VirtualHost>


<Directory /srv/www/htdocs/mydomain-secure>
SSLRequireSSL
</Directory>


Don't change Listen 80 to 443 in /etc/httpd/conf/httpd.conf. SSL is configured in /etc/httpd/conf.d/ssl.conf.
SSL is enabled and listening by default with a self signed certificate.



You can get to the default site using SSL just by browsing to https://localhost (you don't need to add the port to the end of the URL).



If you want to forward all HTTP requests to HTTPS (which is what I believe you are trying to achieve), you can either add a permanent redirect, or use the Apache module mod_rewrite.



The easiest and most secure way is to set up a permanent redirect. Enable named virtual hosts and add a Redirect directive to the VirtualHost in /etc/httpd/conf/httpd.conf.






share|improve this answer













Step 1: Use OpenSSL to produce the keys that are used to secure your
site. These keys are used when encrypting and decrypting the traffic
to your secure site.




$openssl genrsa -out mydomain.key 1024



Step 2: Generate your own certificate .




 $ openssl req -new -key mydomain.key -x509 -out mydomain.crt



Step 3: Keep the pricate key in the directory /etc/apache2/ssl.key/
and certificate in the directory /etc/apache2/ssl.crt/.




Note: The ssl.key directory must be only readable by root.




Step 4: Now you need to edit httpd.conf file in /etc/apache2.




Now this file should include content like this:



> <VirtualHost *:80>
>
> ServerAdmin keshav.mohta@dotsquares.com
>
> DocumentRoot /opt/lampp/htdocs/wsdl
>
> ServerName www.mydomain.com
>
> ServerAlias mydomain.com
>
> </VirtualHost>


<VirtualHost *:443>

ServerAdmin keshav.mohta@dotsquares.com

DocumentRoot /opt/lampp/htdocs/wsdl

ServerName mail.mydomain.com

SSLEngine on

SSLCertificateFile /etc/apache2/ssl.crt/mydomain.crt

SSLCertificateKeyFile /etc/apache2/ssl.key/mydomain.key

ErrorLog "/opt/lampp/logs/wsdl_error_log"

TransferLog "/opt/lampp/logs/wsdl_access_log"

</VirtualHost>


<Directory /srv/www/htdocs/mydomain-secure>
SSLRequireSSL
</Directory>


Don't change Listen 80 to 443 in /etc/httpd/conf/httpd.conf. SSL is configured in /etc/httpd/conf.d/ssl.conf.
SSL is enabled and listening by default with a self signed certificate.



You can get to the default site using SSL just by browsing to https://localhost (you don't need to add the port to the end of the URL).



If you want to forward all HTTP requests to HTTPS (which is what I believe you are trying to achieve), you can either add a permanent redirect, or use the Apache module mod_rewrite.



The easiest and most secure way is to set up a permanent redirect. Enable named virtual hosts and add a Redirect directive to the VirtualHost in /etc/httpd/conf/httpd.conf.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '14 at 11:43









mightyteja

113




113












  • there is httpd-ssl.conf for the Virtual host configuration. Is that okay instead on httpd.conf
    – diEcho
    Nov 21 '14 at 11:51










  • I did whatever you have said but now it's block 192.168.xx.xx ( that was working earlier) now every request(localhost,192.xx or 127.0) goes to wsdl directory.
    – diEcho
    Nov 21 '14 at 11:59












  • I just want to run one site on https and rest are on http(like normal). that's all
    – diEcho
    Nov 21 '14 at 11:59












  • Note: Put generated key and certificate on opt/lampp/apache2/ssl folder with 664 permission
    – diEcho
    Nov 21 '14 at 12:26












  • I have updated my question Please see.
    – diEcho
    Nov 24 '14 at 9:53


















  • there is httpd-ssl.conf for the Virtual host configuration. Is that okay instead on httpd.conf
    – diEcho
    Nov 21 '14 at 11:51










  • I did whatever you have said but now it's block 192.168.xx.xx ( that was working earlier) now every request(localhost,192.xx or 127.0) goes to wsdl directory.
    – diEcho
    Nov 21 '14 at 11:59












  • I just want to run one site on https and rest are on http(like normal). that's all
    – diEcho
    Nov 21 '14 at 11:59












  • Note: Put generated key and certificate on opt/lampp/apache2/ssl folder with 664 permission
    – diEcho
    Nov 21 '14 at 12:26












  • I have updated my question Please see.
    – diEcho
    Nov 24 '14 at 9:53
















there is httpd-ssl.conf for the Virtual host configuration. Is that okay instead on httpd.conf
– diEcho
Nov 21 '14 at 11:51




there is httpd-ssl.conf for the Virtual host configuration. Is that okay instead on httpd.conf
– diEcho
Nov 21 '14 at 11:51












I did whatever you have said but now it's block 192.168.xx.xx ( that was working earlier) now every request(localhost,192.xx or 127.0) goes to wsdl directory.
– diEcho
Nov 21 '14 at 11:59






I did whatever you have said but now it's block 192.168.xx.xx ( that was working earlier) now every request(localhost,192.xx or 127.0) goes to wsdl directory.
– diEcho
Nov 21 '14 at 11:59














I just want to run one site on https and rest are on http(like normal). that's all
– diEcho
Nov 21 '14 at 11:59






I just want to run one site on https and rest are on http(like normal). that's all
– diEcho
Nov 21 '14 at 11:59














Note: Put generated key and certificate on opt/lampp/apache2/ssl folder with 664 permission
– diEcho
Nov 21 '14 at 12:26






Note: Put generated key and certificate on opt/lampp/apache2/ssl folder with 664 permission
– diEcho
Nov 21 '14 at 12:26














I have updated my question Please see.
– diEcho
Nov 24 '14 at 9:53




I have updated my question Please see.
– diEcho
Nov 24 '14 at 9:53


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f843147%2fhttps-redirect-to-virtual-host-directory-and-http-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

QoS: MAC-Priority for clients behind a repeater

Ивакино (Тотемский район)

Can't locate Autom4te/ChannelDefs.pm in @INC (when it definitely is there)