Category Archives: apache

Problems setting up a new whitelabel service via CNAME

I have a SAAS and am trying to allow other people to use my SAAS in their own domain. So, supposing my site is app.example.com (hosted with Apache and with PHP as the backend language), I want to allow someone to offer my website from, for example, app.anotherwebsite.com.

I already created a CNAME on app.anotherwebsite.com:

app.anotherwebsite.com CNAME app.example.com.

But if I access app.anotherwebsite.com, it loads the default cPanel page on app.anotherwebsite.com/cgi-sys/defaultwebpage.cgi.

I already tried many solutions offered on the web with no luck. Does anyone have any clue how to solve this? Do I have to do something on the example.com server to fix this?

Thanks a lot!

Problems setting up a new whitelabel service via CNAME

I have a SAAS and am trying to allow other people to use my SAAS in their own domain. So, supposing my site is app.example.com (hosted with Apache and with PHP as the backend language), I want to allow someone to offer my website from, for example, app.anotherwebsite.com.

I already created a CNAME on app.anotherwebsite.com:

app.anotherwebsite.com CNAME app.example.com.

But if I access app.anotherwebsite.com, it loads the default cPanel page on app.anotherwebsite.com/cgi-sys/defaultwebpage.cgi.

I already tried many solutions offered on the web with no luck. Does anyone have any clue how to solve this? Do I have to do something on the example.com server to fix this?

Thanks a lot!

Why does docker-compose use different images/containers for each stack service?

I am migrating from a MAMP stack to docker and can't seem to understand why the interesting docker-compose approach is designed to run different linked containers for every service (say php, mysql, apache) instead of having a container for it all, for the sake of an actual virtual host emulating a whole desired scenario.

Why is it not practical to have them all together?

How to redirect www to non-www https?

I have installed https on my domain. And all this cases are available of my website:

http://example.com        // will be redirected to https://example.com
https://example.com
http://www.example.com    // will be redirected to https://www.example.com
https://www.example.com

See? everything will be using https protocol. All fine.


Now I need to redirect all www to non-www. So http://www.example.com and https://www.example.com should be redirected to https://example.com (in other word, all cases should be redirected to this).

Here is my current code in the /etc/apache2/sites-avalible/000-default.conf:

<VirtualHost *:80>
.
.
.
RewriteEngine on
RewriteCond %{SERVER_NAME} =lamtakam.com [OR]
RewriteCond %{SERVER_NAME} =www.lamtakam.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]               -- this
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]              -- and this are for www redirection
                                                        -- but doesn't work
</VirtualHost>

any idea?

also lamtakam is my exact domain I was talking about, if you need to check something.

RegEx for ${any_text} [duplicate]

This question already has an answer here:

I'm trying to find any solution to extract all variables definition from freemaker template. Lets assume that template looks like this:

Hello ${test_1} Hello ${test_2} Hello ${test_3} Hello ${test_4}

At the output I want to have list of test_1, test_2, test_3, test_4. I tried almost every approach but this $ (special character sign) is causing me a lot of problems also important thing (that also cause me problem) are variables that relate for objects for example ${test_1.user.name}

Why is my POST request returning 400? URL and JSON are validated as OK

I have some code that is returning a 400 response code:

try {
        // Set the String Entity version of the JSON to be sent
        StringEntity entity = new StringEntity(payload1.toString());

        // Create HTTP Client
        HttpClient client = HttpClientBuilder.create().build();

        // Create Request Object
        HttpPost post = new HttpPost(destination);
        post.addHeader("Content-Type", "application/json");
        post.setEntity(entity);

        // Execute the request
        System.out.println("Sending request...");
        HttpResponse response = client.execute(post);

        System.out.println(response.getStatusLine().getStatusCode());
}
catch (Exception e) {
        e.printStackTrace();
}

I know that payload1.toString() works, I have validated it as JSON with this JSON validator. I also know that the request works with the endpoint, I sent the payload1.toString() to destination using ApiRequest.io and it popped up correctly on the other side.

Please help!! What am I missing?

How to setup the right config in two nested symfony applications?

I have two symfony application sf1 and sf3 (sf3 inside sf1) .i start with SF1 because the entry points are in sf1 (DocumentRoot "${PORTALROOT}/web" ) and sf1 need a database already configured to be loaded. home page .

I created a Bundle inside sf3 (localhost/setup)setup for the installation of the application and the setting up of the database ... the problem is i can t load the page localhost/setup because we don t have a database yet.

here is my vhost.conf

Listen 8000

Define PORTALROOT "C:/workspace/portal/openbeeportal"

DocumentRoot "${PORTALROOT}/web"

<Directory "${PORTALROOT}/web/">
    AllowOverride All
    Options -Includes -ExecCGI

    <Files autosign.php>
        AuthName "Intranet"
        AuthType SSPI
        SSPIAuth On
        SSPIAuthoritative On
        SSPIOfferBasic Off
        SSPIPerRequestAuth On
        SSPIOmitDomain Off
        require valid-user
    </Files>

    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order Allow,Deny
        Allow from All
    </IfModule>***vhost***
</Directory>

How to setup the right config in two nested symfony applications?

I have two symfony application sf1 and sf3 (sf3 inside sf1) .i start with SF1 because the entry points are in sf1 (DocumentRoot "${PORTALROOT}/web" ) and sf1 need a database already configured to be loaded. home page .

I created a Bundle inside sf3 (localhost/setup)setup for the installation of the application and the setting up of the database ... the problem is i can t load the page localhost/setup because we don t have a database yet.

here is my vhost.conf

Listen 8000

Define PORTALROOT "C:/workspace/portal/openbeeportal"

DocumentRoot "${PORTALROOT}/web"

<Directory "${PORTALROOT}/web/">
    AllowOverride All
    Options -Includes -ExecCGI

    <Files autosign.php>
        AuthName "Intranet"
        AuthType SSPI
        SSPIAuth On
        SSPIAuthoritative On
        SSPIOfferBasic Off
        SSPIPerRequestAuth On
        SSPIOmitDomain Off
        require valid-user
    </Files>

    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order Allow,Deny
        Allow from All
    </IfModule>***vhost***
</Directory>

Prestashop backround bulk product import

I'm trying to import efficently 15K+ products periodically in a Prestashop e-commerce parsing an ASCII file (3.5MB) and using only Prestashop's API.

All run under docker, with official images from docker hub.

If a product with the same reference field does not exists I'll have to insert a new product, if it's present to update it. I developed a module that makes this via a click un a custom admin tab, and it works, but the whole system freezes till the process is finished or terminated: (almost 77 minutes). I also tried to split the (not so) big file in chunks of 500, 100, 50 but the time for the processing decreases linearly, it doesn't help very much:

  • 153 avg seconds for 500 elements
  • 31 avg seconds for 100 elements
  • 15 avg seconds for 50 elements

I could surely configure a cron every 90 seconds to process 50 elements, and complete the whole import in 7-8 nightly hours, but it seems a very bad compromise: 15 seconds offline every 90...

I cannot use pthreads since this will be a production web server.

I tried to tune Apache increasing memory_limit, max_input_vars, max_execution_time but without any differences: DB using from 450MB to 550MB of RAM and server almost identical.

Linux #1 SMP Debian 4.9.110-3+deb9u6 (2018-10-08) x86_64

Versione software del server: Apache/2.4.10 (Debian)

Versione di PHP: 5.6.35

memory_limit=2048M

max_input_vars=1000000

max_execution_time=600000

MySQL: 5.6.40

Am I facing the problem in the wrong way, or Prestashop's API are not performant and made for bulk (and performant) product import?

public function batchImportAllProductsFromFile($productsToBeInserted){
    foreach ($productsToBeInserted as $key => $customProduct ) {

        $productIDs = $this->getProductIDsByReference($customProduct->MS_CODMAG);
        if (sizeof($productIDs) == 0) {
            $product = new Product();
        } else if (sizeof($productIDs) == 1) {
            $product = new Product($productIDs[0]);
        } else {
            continue;
        }

        $product->reference = $customProduct->MS_CODMAG;
        $product->name = trim($customProduct->MS_DESCRIZIONE);
        $product->price = $customProduct->MS_PREZZO_1;
        $product->out_of_stock = ($customProduct ->MS_ESAURITO === "S" ? true : false);

        $category = null;

        $msGruppoConverted = $this->buildSubGroupCode($customProduct->MS_GRUPPO, $customProduct->MS_SGRUPPO);

        if ($customProduct->MS_GRUPPO !== 0 && $msGruppoConverted !== 0) {
            $product->id_category = [$customProduct->MS_GRUPPO, $msGruppoConverted];
        } else if ($customProduct->MS_GRUPPO === 0 && $msGruppoConverted !== 0) {
            $product->id_category = [$msGruppoConverted];
        } else if ($customProduct ->MS_GRUPPO !== 0 && $msGruppoConverted === 0) {
            $product->id_category = [$customProduct->MS_GRUPPO];
        }
        try {
            if (sizeof($productIDs) == 0) {
                if ($product->add()) {
                    $product->updateCategories($product->category);
                    $product->addFeatureProductImport($product->id, 1, $customProduct->MS_FAM);
                    //StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, Context::getContext()->shop->id);
                }
            } else if (sizeof($productIDs) == 1) {
                if ($product->update()) {
                    $product->updateCategories($product->category);
                    $alreadySavedFeatures = $product->getFeaturesStatic($productIDs[0]);
                    if (sizeof($alreadySavedFeatures) != 1 || $alreadySavedFeatures[0] != $customProduct->MS_FAM) {
                        $product->deleteProductFeatures();
                        $product->addFeatureProductImport($product->id, 1, $customProduct->MS_FAM);
                    }
                }
            }
        } catch (Exception $e) {
            var_dump("Errore: ", $e, $product);
        }
    }
}