'How to change Pact Broker Context Path?

We are using pactfoundation/pact-broker image of version 2.93.X.X or higher.

We want to change the context path of the pact broker. In documentation, it is mentioned to set PACT_BROKER_BASE_URL environment variable to change the context path.

When we are using the below properties:

PACT_BROKER_PORT=<CUSTOMER_PORT_NUMBER>
PACT_BROKER_DATABASE_URL=<DB_URL>
PACT_BROKER_BASE_URL=http://<COMPANY_DOMAIN>:<CUSTOMER_PORT_NUMBER>/pactbroker

And trying to access http://<COMPANY_DOMAIN>:<CUSTOMER_PORT_NUMBER>/pactbroker below is the error message we are receiving,

404 Not Found    
The requested document was not found on this server.    
Webmachine-Ruby/1.6.0 server

NOTE: When we are not using PACT_BROKER_BASE_URL environment variable then everything is working fine. But we what to change the context path. How can we achieve that?



Solution 1:[1]

The broker itself is not aware of a context path, this is the responsibility of a web server (e.g. nginx or Apache). The base URL property is used in conjunction with however you are running the broker.

If you want to run it on a different context path, you'll need to configure your web server.

See also https://docs.pact.io/pact_broker/configuration/features#running-the-broker-behind-a-reverse-proxy

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matthew Fellows