Hi everyone, I have set up a WireMock server usin...
# help
a
Hi everyone, I have set up a WireMock server using the standalone JAR file, and it is currently serving HTTPS requests at https://192.168.232.32:8443. I would like to configure the server to act as a selective proxy. Specifically, I want certain curl requests made to the WireMock server to be forwarded to https://192.168.232.32:5000, while other requests should be handled directly by the WireMock server. Can anyone guide me on how to achieve this setup?
t
Proxying is achieved in WireMock via stubs in the same way as serving responses directly, so you can configure e.g. one stub with some specific criteria for proxying and another for a canned response: Proxy:
Copy code
{
  "request": {
    "urlPathPattern": "/to/proxy.*"
  },
  "response": {
    "proxyBaseUrl": "<https://192.168.232.32:5000>"
  }
}
Direct:
Copy code
{
  "request": {
    "urlPathPattern": "/do-not/proxy.*"
  },
  "response": {
    "status": 200,
    "body": "This was not proxied"
  }
}
You can use any request criteria you like in either stub, so method, headers, query, body etc. in addition to URL.
a
Thanks @Tom for guiding, but will there be any need to exchange the certificates between https://192.168.232.32:8443 and https://192.168.232.32:5000 for mTLS. I am running my wiremock server as follow : java -jar wiremock-standalone-3.9.2.jar --https-port 8443--https-keystore server.jks --keystore-password password --https-require-client-cert --https-truststore truststore.jks --truststore-password password And the request to wiremock server is sent as : curl -k --cert client.crt --key client.key --cacert ca.crt -X GET https://192.168.232.32:8443/do-not/proxy -H "Content-Type: application/json" Just want to clear my doubt as I am very new to this kind of setup.