0
votes

I am working server side and I had a problem. I am use XAMPP and Apache server in my server. First, I buy a static IP and I open port for access everyone.

I can succesfully when: "http://{StaticIP}/api/NewsJson". But when I try "https://{StaticIP}/api/NewsJson", I take 403 error in browser. I search and I find some solves.

First, I change line in "xampp\apache\conf\extra\httpd-xampp" folder. I change local granted change require all granted.

ScriptAlias /php-cgi/ "C:/xampp/php/"
<Directory "C:/xampp/php">
    AllowOverride None
    Options None
    Require all granted
    <Files "php-cgi.exe">
          Require all granted
    </Files>
</Directory>

<Directory "C:/xampp/cgi-bin">
    <FilesMatch "\.php$">
        SetHandler cgi-script
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler None
    </FilesMatch>
</Directory>

<Directory "C:/xampp/htdocs/xampp">
    <IfModule php7_module>
        Require all granted
        <Files "status.php">
            php_admin_flag safe_mode off
        </Files>
    </IfModule>
    AllowOverride AuthConfig
</Directory>

<IfModule alias_module>
    Alias /licenses "C:/xampp/licenses/"
    <Directory "C:/xampp/licenses">
        Options +Indexes
        <IfModule autoindex_color_module>
            DirectoryIndexTextColor  "#000000"
            DirectoryIndexBGColor "#f8e8a0"
            DirectoryIndexLinkColor "#bb3902"
            DirectoryIndexVLinkColor "#bb3902"
            DirectoryIndexALinkColor "#bb3902"
        </IfModule>
    Require all granted
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
   </Directory>

    Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
    Require all granted
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

    Alias /webalizer "C:/xampp/webalizer/"
    <Directory "C:/xampp/webalizer">
        <IfModule php7_module>
            <Files "webalizer.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
    Require all granted
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>
</IfModule>

Then, I add this line in "xampp\apache\conf\extra\httpd-vhosts" folder.

    <VirtualHost *:80>
                DocumentRoot "C:/xampp/htdocs/api/NewsJson"
                ServerName 192.168.*.** (My Server IP)
                <Directory "C:/xampp/htdocs/api/NewsJson">
                    Options Indexes FollowSymLinks Includes ExecCGI
                    AllowOverride All
                    Order allow,deny
                    Allow from all
                    Require all granted
                </Directory>
            </VirtualHost>

    <VirtualHost *:443>
            DocumentRoot "C:/xampp/htdocs/api/NewsJson"
                ServerName 192.168.*.** (My Server IP)
                <Directory "C:/xampp/htdocs/api/NewsJson">
                    Options Indexes FollowSymLinks Includes ExecCGI
                    AllowOverride All
                    Order allow,deny
                    Allow from all
                    Require all granted
                </Directory>
            </VirtualHost>

<VirtualHost *:443>
 DocumentRoot "C:/xampp/htdocs/api/NewsJson"
 ServerName 192.168.*.** (My Server IP)
 SSLEngine on
 SSLCertificateFile "C:/xampp/apache/conf/ssl.crt/server.crt"
 SSLCertificateKeyFile "C:/xampp/apache/conf/ssl.key/server.key"
</VirtualHost>

And I change my ".htaccess" folder.

RewriteEngine On
RewriteRule NewsJson.html$ NewsJson.php [L]

When I change them, I closed Apache and open again. But, I take still 403 forbidden error. What can I solve this problem?

AH00112: Warning: DocumentRoot [C:/xampp/htdocs/api/NewsJson] does not exist
AH00112: Warning: DocumentRoot [C:/xampp/htdocs/api/NewsJson] does not exist
[Thu Aug 22 14:47:29.161955 2019] [ssl:warn] [pid 5332:tid 384] AH01909: StaticIP:80:0 server certificate does NOT include an ID which matches the server name
[Thu Aug 22 14:47:29.161955 2019] [ssl:warn] [pid 5332:tid 384] AH01915: Init: (StaticIP:80) You configured HTTPS(443) on the standard HTTP(80) port!
1

1 Answers

0
votes

In order to be able to access your projects via HTTPS in the browser, you must first set up an SSL certificate on your Apache server. By itself, XAMPP does not do that, so you have to act manually at this point.

How this works is explained in the tutorial on how to set up SSL/HTTPS for local XAMPP projects. https://www.askingbox.com/tutorial/xampp-how-to-set-up-ssl-https-for-local-projects