Hi! I am trying to run pact broker at a different ...
# pact-broker
m
Hi! I am trying to run pact broker at a different context-path other than / and trying that using below nginx conf
server {
listen      80 default_server;
server_name localhost:9292;
location / {
rewrite ^(.*)$ /pact$request_uri permanent;
}
location /pact {
proxy_pass <http://localhost:9292>;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Even after mutiple tries, its showing up the broker page on / and /pact is giving a 404. Do I need to change any other configs to configure the web server?
m
m
yes I configured that as well
As per the docs,
It is also required when deploying the Broker behind a reverse proxy, and when the application has been mounted at a non-root context. Note that this attribute does not change where the application is actually mounted (that is the concern of the deployment configuration) - it just changes the links.
How do we change the dpeloyment to run as non-root context?
y
What does your pact broker configuration look like? Can you provide a public sample? This looks like its not too far removed from the pact-broker-docker nginx sample in the repo so that would be a good starter from which to create a repro
m
Hi@Yousaf Nabi (pactflow.io) This is the docker-compose file we are using to build the services.
Copy code
version: "3"

services:
  postgres:
    image: postgres
    healthcheck:
      test: psql postgres --command "select 1" -U postgres
    volumes:
      - postgres-volume:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: postgres

  pact-broker:
    image: "pactfoundation/pact-broker:2.113.0-pactbroker2.107.1"
    ports:
      - "9292:9292"
    depends_on:
      - postgres
    environment:
      PACT_BROKER_PORT: '9292'
      PACT_BROKER_DATABASE_URL: "<postgres://postgres:password@postgres/postgres>"
      PACT_BROKER_LOG_LEVEL: DEBUG
      PACT_BROKER_SQL_LOG_LEVEL: DEBUG
    
      PACT_BROKER_DATABASE_CONNECT_MAX_RETRIES: "5"
     
      PACT_BROKER_BASE_URL: '<http://localhost:9292/pact>'
      pactbroker.base_url: '<http://localhost:9292/pact>'

  # Nginx is not necessary, but demonstrates how
  # one might use a reverse proxy in front of the broker,
  # and includes the use of a self-signed TLS certificate
  nginx:
    image: nginx:alpine
    depends_on:
      - pact-broker
    volumes:
      - ./ssl/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - ./ssl:/etc/nginx/ssl
    ports:
      - "443:443"
      - "80:80"
volumes:
  postgres-volume:
cc: @MANALI KHANNA
m
I don’t think the base URL is right either. It’s what the URL should look like to the user, in your case it would be
<http://localhost/pact>
(if port 80) or
<https://localhost/pact>
for TLS
It looks like the nginx setup is probably to blame. it’s at nginx where you would setup the context path
do you even need the context path though?
m
@Matt (pactflow.io / pact-js / pact-go) Yes we need the context path since we are using path based routing from our Ingress in the deployment process
👍 1
@Matt (pactflow.io / pact-js / pact-go) Do you see anything that we are missing in nginx conf file?
m
Do you see anything that we are missing in nginx conf file?
this is really an nginx question, it’s been a while and I can’t recall the syntax for doing so