getting 404 for proxy transparent

59 views
Skip to first unread message

Vamsi Devalla

unread,
Jun 22, 2023, 10:09:21 PM6/22/23
to mountebank-discuss
my config 
{
  "imposters": [
    {
      "protocol": "https",
      "port": 8080,
      "name": "{{name}} imposters",
      "_links": {
        "self": {
          "href": "http://localhost:2525/imposters/8080"
        }
      },
      "stubs": [
        {
          "predicates": [
            {
              "equals": {
                "method": "GET",
                "path": "/test"
              }
            }
          ],
          "responses": [
            {
              "is": {
                "statusCode": 200,
                "headers": {
                  "Content-Type": "application/json"
                },
                "body": {}
              }
            }
          ]
        },
        {
          "responses": [
            {
              "proxy": {
                "to": "https://redir.com",
                "mode": "proxyTransparent",
                "addWaitBehavior": true,
                "predicateGenerators": [
                  {
                    "matches": {
                      "path": true
                    }
                  }
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}

my etc/host config
xx.xx.xx.209     redir.com

i am getting response for localhost:8080/test but i am getting 404 for all other requests that proxied to redir.com

Vamsi Devalla

unread,
Jun 22, 2023, 11:26:16 PM6/22/23
to mountebank-discuss
I think I found the issue. Node.js does not check the host mapping in the hosts file by default. To enable this feature, you need to set the host option to true when creating the https.Server instance. may be we should allow user to add this also as imposter config. which can be used in https://github.com/bbyars/mountebank/blob/331e8636ab78f4bcfec390a454fd886e8760ff4b/src/models/https/httpsServer.js#L13C10-L13C26
Reply all
Reply to author
Forward
0 new messages