Getting SSL to work in Xampp - Access forbidden error

I am trying to get Xampp to work in https, but I have a few problems.

What i have done so far:

  • mod_ssl.so loaded
  • php_openssl.dll loaded
  • The DocumentRoot in httpd-ssl.conf has been changed from C: / xampp / htdocs to C: / xampp /, since all the directories of my sites are located here.

Do I need to change the server name in httpd-ssl.conf?

Edit: do I need to add a virtual host in httpd-vhosts.conf on port 443 as well as 80? In addition, Xampp comes with built-in SSL certificate, etc.

+5
source share
1 answer

The best way is to create VirtualHost for each project you develop. Otherwise, you will need to modify the DocumentRoot for the project that you are developing at that time.

Thus, you can modify the "httpd-vhosts.conf" file and create a VH for port 80 by redirecting all requests to VH for port 443 (if you want to disable only HTTP), for example like this:

• HTTP

<VirtualHost *:80> ServerName yoursite.your.domain Redirect / https://yoursite.your.domain/ </VirtualHost> 

• HTTPS

 <VirtualHost *:443> ServerName yoursite.your.domain:443 #in your case you're not using htdocs, so DocumentRoot be like DocumentRoot "C:\xampp\yourproject" <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" Header always set Access-Control-Allow-Methods "POST, PUT, GET, DELETE, OPTIONS" Header always set Access-Control-Allow-Headers "Content-Type" </IfModule> #the same here <Directory "C:\xampp\yourproject"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory> #check your absolute path bellow SSLEngine on SSLCertificateFile "C:\xampp\apache\conf\ssl.crt\server.crt" SSLCertificateKeyFile "C:\xampp\apache\conf\ssl.key\server.key" </VirtualHost> 

As for the certificate, I think that XAMPP actually comes with a built-in SSL certificate, but even if it did not come, you can generate it using its tools. You can see many lessons on the Internet about this.

0
source

Source: https://habr.com/ru/post/1214303/


All Articles