KB00008:PartKeepr behind a reverse proxy

From PartKeepr Wiki
Revision as of 19:13, 22 April 2018 by Felicitus (talk | contribs) (Created page with "= PartKeepr behind a reverse proxy = Sometimes it's required to run PartKeepr behind a reverse proxy. Depending on your setup, there are two possibilities. In this example, <...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PartKeepr behind a reverse proxy

Sometimes it's required to run PartKeepr behind a reverse proxy. Depending on your setup, there are two possibilities. In this example, http://internal-partkeepr/ could run on an internal virtual machine, not accessible from the outside.

The first case is simple, nothing needs to be done in that case - this should work with all PartKeepr versions.

The second case is a bit more difficult: PartKeepr loads the frontend resources like images and javascripts from URLs, but these must be known to PartKeepr to properly generate them. As PartKeepr only has the information where it is called on (like the virtual machine in our example), it doesn't know that the user's browser expects the resources to be below https://example.org/parts/ and would generate links like https://example.org/ - now the user's browser can't find them.

Starting from PartKeepr 1.4, it is possible to configure a fixed external URL to solve that problem.

To configure it, you need to make two settings.

In your app/config/parameters.php file, add the following line where you configure the first external url:

$container->setParameter('partkeepr.frontend.base_url', "https://www.example.org/parts/");

Additionally, create a file called app/config/config_custom.yml and configure your external url as well. Note the proper indentation!

framework:
    assets:
        base_urls:
            - 'https://www.example.org/parts/'

Now re-run setup or re-generate your environment and you should see that the generated URLs in the PartKeepr frontend all begin with the url you've set.

It is important to note that this only works in the production environment - it will not work in the dev environment!