1

A customer asked me to install a tls-certificate on his web server and make for http->https redirection. After installing the certificate and adjusting the rewrite rules as follows everything seemed to work fine:

    RewriteEngine on

    RewriteCond %{HTTP_HOST} !^www\. [NC] [OR]
    RewriteCond %{HTTPS} off 
    RewriteRule (.*) https://www.example.com%{REQUEST_URI} [R=301,L]


############################################
## rewrite API2 calls to api.php (by now it is REST only)

    RewriteRule ^api/rest api.php?type=rest [QSA,L]

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]
<IfModule mod_setenvif.c>
    <IfModule mod_headers.c>

        ############################################
        # X-Content-Type-Options: nosniff disable content-type sniffing on some browsers.
        Header set X-Content-Type-Options: nosniff

        ############################################
        # This header forces to enables the Cross-site scripting (XSS) filter in browsers (if disabled)
        BrowserMatch \bMSIE\s8 ie8
        Header set X-XSS-Protection: "1; mode=block" env=!ie8

    </IfModule>
</IfModule>

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

BUT: there is a cron job installed via the webmin panel which looked like this prior to the installation of the http->https redirection:

wget -O /dev/null http://example.com/some_api

Unfortunately the customer does not know much about the API and I cannot read the documentation, since I have no command of the language in which it is written.

What I found out was that the above call triggers a synchronization process (product data) between the (magento) shop and the mongo db installed in the system.

I tried to adapt the above call to the http->https redirection using the following new command line:

wget -O /dev/null --ca-directory /home/user https://www.example.com/some_api

but now the sync does not work any more (i had to prepend the "www" to the originally used host name since the request otherwise hung for ages).

When launched manually from within webmin, I get the following output:

--2018-09-28 18:00:32--  https://www.example.com/some_api
Resolving www.example.com (www.example.com)... 46.xxx.yyy.zzz
Connecting to www.example.com (www.example.com)|46.xxx.yyy.zzz|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://example.com/ [following]
--2018-09-28 18:00:32--  https://example.com/
Resolving example.com (example.com)... 46.xxx.yyy.zzz
Connecting to example.com (example.com)|46.xxx.yyy.zzz|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `/dev/null'

     0K .......... .......... .......... .......... .......... 57.4M
    50K .......... .......... .......... ........              4.50M=0.009s

2018-09-28 18:00:33 (9.40 MB/s) - `/dev/null' saved [90479]

Obviously the request is redirected to DocumentRoot directory (containing the index.php file), but the sync is not executed.

From this point I do not know how to proceed further, since my know-how about APIs and their behaviour under the mentioned conditions is scarce. Maybe a proper rewrite of the URL would be sufficient already.

So, my question is: How do I get the API call work again?

closed as too broad by DavidPostill Sep 28 '18 at 20:00

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.