How to set up CDN access for Magento 2

    October 16, 2019

    How Nexcess clients can use the Client Portal to configure their CDN service for use with their Magento 2 store.

    What you need

    • An active CDN service with Nexcess. To order a Nexcess service plan, visit our website.
    • A functioning Magento store on your Nexcess server.
    • Your Client Portal username and password. If you cannot locate this information, click the Reset Password link on the Client Portal login menu or contact our support team.

    Exception for media assets

    Certain types of content, such as images, video, and audio media assets like JPG, MP3, MP4, and so on, are already compressed. Additional compression to these types of assets will not significantly diminish file size. Therefore, it is recommended you do not enable compression for these asset types.

    Method

    To learn how to configure CDN access for Magento 1, see How to configure CDN access for Magento.

    1: Access the CDN control panel

    1. If you have not already done so, purchase a Nexcess CDN plan or use a Magento hosting plan that comes with CDN access. If you plan already includes a CDN but you do not see one listed, contact our 24/7 support team for assistance.

    2. Log in to the Client Portal. From the dashboard, click Service > Other.
    3. Locate the relevant CDN service. From the menu toggle, followed by CDN Control Panel.
    4. When prompted, choose your preferred language.

    2: Configure large HTTP delivery

    ATTENTION: You must enable CDN compression as instructed below for both the HTTP large and HTTP small delivery methods to fully utilize the CDN’s compression utility.

    1. Select HTTP Large > Customer Origin.

    2. In the Directory Name field, enter your preferred name, such as “magento.”

    3. In the Hostname or IP Address field, type the web address (URL) of your store; for example, store.nexcess.net.
    4. Near the Hostname or IP Address field, click Add.
      Screenshot - 6_10_2015 , 10_57_18 AM.png
    5. On the lower right in the HTTP Large Object Customer Origins control panel, click Add.
    6. Setup for your large HTTP delivery is now complete. Proceed to the “Configure small HTTP delivery” section.

    3: Configure small HTTP delivery

    1. Select HTTP Small > Customer Origin.
      Screenshot - 6_10_2015 , 11_23_22 AM.png
    2. In the Directory Name field, enter your preferred name, such as “magento” (see below image).

    3. In the Hostname or IP Address field, type the URL of your store; for example, store.nexcess.net.
    4. Near the Hostname or IP Address field, click Add.
      Screenshot - 6_10_2015 , 10_57_18 AM.png
    5. On the lower right in the HTTP Small Object Customer Origins control panel, click Add.
      Screenshot - 6_10_2015 , 11_31_49 AM.png
    6. Setup for your small HTTP delivery is now complete. After waiting about one hour to give the CDN service time to cache your data, proceed to the “Verify settings” section.

    4: Verify settings

    ATTENTION: Allow the CDN service at least one hour to cache your data before you attempt to verify the new settings as outlined below. 

    To verify both large and small customer origins, use the URLs provided in the Customer Origin panel and append destinations specific to Magento:

    1. To test the small HTTP customer origin:
      1. Locate your store’s URL in the HTTP Small Object Customer Origins control panel.
        Screenshot - 6_10_2015 , 11_45_25 AM.png
      2. Append /js/mage/cookies.js to your store’s URL. From the example URL shown in the above image, the appended URL would read: http://smhttp.42588.nexcesscdn.net/8016fc0/magento/js/mage/cookies.js

      3. Enter the appended URL into your web browser. If the page loads, your assets have successfully propagated to the CDN and you may proceed to Step 2. If you have already completed Step 2, proceed to the next section.

    2. To test the large HTTP customer origin, repeat Step 1 from the HTTP Large Object Customer Origins Panel.

    5: Update your Magento 2 installation

    1. Update your Magento install to use the new large and small origin URLs by selecting Stores > Configuration > Web.
    2. From the General tab, select Web.
    3. From the Store View drop-down list, select your desired store.
    4. In the Base URL (Secure) section, in the Base URL for Static View Files field, enter the small origin URL you created in the “Configure small HTTP delivery” section, Step 6.
    5. In the same section, in the Base URL for User Media Files field, enter large origin URL you created in the “Configure large HTTP delivery” section, Step 6 (see above image).

    6. Flush the Magento 2 cache:
      1. From the main menu, select System > Cache Management.
      2. On the upper right, click Flush Magento Cache.

    6: Purge the CDN cache

    Follow the procedure given in How to purge the CDN cache.

    7: Activate CDN compression

    Follow the procedure provided in How to activate CDN compression.


    For 24-hour assistance any day of the year, contact our support team by email or through your Client Portal.

    Was this article helpful?

    Send feedback

    Can’t find what you’re looking for?

    Our award-winning customer care team is here for you.

    Contact Support