Hello! I'm trying to setup pact broker in a develo...
# pact-broker
p
Hello! I'm trying to setup pact broker in a development environment. I would like for the end users to be able to access the UI via a reverse proxy, and have the publication/verification instructions from services execute internal to the reverse proxy. I've noticed that the initial publication request by a service (PactBroker:Client:PublicationTask) uses the locally defined pact_broker_base_url initially, but it is eventually replaced by the base_url defined in the Pact Broker configuration. I've poked around and this definitely appears to be the desired behavior. This is presenting a problem. The publication task needs to use the internal URL to publish, but the UI needs to use the external URL provided by the reverse proxy. And it seems as though either the UI js will break (see attached), or the publication task will break. Now, if we mount pact-broker to the root path of the service, and remove the base_url variable from the pact-broker configuration, then everything works! However, this isn't a good option for a variety of reasons (Authentication/other desired routing). If/when we get this running in CI, this probably won't be an issue as both the UI and publication requests will both originate from outside of the reverse proxy. But for development work this is pretty annoying. If we are defining the publication URL in each service, why would this get overridden by a configuration in the broker? Thanks! cc @Andy Jenness
👋 1
y
p
Hi @Yousaf Nabi (pactflow.io). I recently was able to get the appropriate headers added I beleive:
*"*HTTP_X_FORWARDED_SCHEME*"*=>*"*https*"*,
*"*HTTP_X_FORWARDED_HOST*"*=>*"*<http://contract-testing-service.chm.life|contract-testing-service.chm.life>*"*,
*"*HTTP_X_FORWARDED_PORT*"*=>*"*443*"*,
*"*HTTP_X_FORWARDED_SSL*"*=>*"*on*"*,
We've mounted and configured pact-broker as such:
app = PactBroker::App.new do |config|
binding.pry
config.port = "8000"
config.log_stream = :stdout
config.log_level = :debug
# config.log_level = :info
config.basic_auth_enabled = false # set to true to enable the user below
config.basic_auth_username = ENV["BASIC_AUTH_USERNAME"]
config.basic_auth_password = ENV["BASIC_AUTH_PASSWORD"]
config.basic_auth_read_only_username = ENV["AUTH_READ_ONLY_USERNAME"]
config.basic_auth_read_only_password = ENV["AUTH_READ_ONLY_PASSWORD"]
config.database_url = "postgres://#{ENV["POSTGRES_USER"]}:#{ENV["POSTGRES_PASSWORD"]}@#{ENV["POSTGRES_HOST"]}/#{ENV["POSTGRES_NAME"]}"
config.base_url = "<http://contract-testing-service/pact>"
end
Rails.application.routes.draw do
mount app => "/pact"
get :ping, to: "ping#ping", defaults: { format: :json }
end
It seems like everything is working well, and the headers appear to be present with all requests, but the application still seems to be using the base_url default for the UI.
Ok - I realize I need to replace base_url with base_urls and include the proxy address as well. Haven't quite gotten it working, but seeing some promising behavior now. 🤞
Ok! It works. Was using base_url instead of base_urls and including the additional URL.
🦆
😆 1
m
Thanks for sharing!
y
Got to love a bit of rubber ducky programming 🙂 If you want to propose any changes to the docs, that would have helped out past you, you can 👍
☝️ 1
Glad you got sorted!