smocker-dev / smocker

Smocker is a simple and efficient HTTP mock server and proxy
https://smocker.dev
MIT License
1.14k stars 61 forks source link

Setting `Host` header for proxy isn't working #235

Closed tino closed 2 years ago

tino commented 2 years ago

I'm trying to run (from a docker container) with these proxy settings:

  proxy:
      host: http://host.docker.internal:8000/
      headers:
          Host:
            - myapp.localhost
          X-foo-bar:
            - myval

This results in my app properly seeing the X-foo-bar header, but the Host header is still set to host.docker.internal (and my app doesn't like that).

I have no idea how to fix this?

Thiht commented 2 years ago

It's an issue on our side, we need to interpret some specific headers (Host, User-Agent, etc.) differently according to https://github.com/golang/go/issues/29865#issuecomment-456305804 and https://github.com/golang/go/issues/29865#issuecomment-456516118

I'll try to do the fix next week

Thiht commented 2 years ago

Nevermind, this is actually already implemented1. You can provide the parameter keep_host: true to your mock declaration (see: https://smocker.dev/technical-documentation/mock-definition.html#format-of-proxy-section)

tino commented 2 years ago

Ah thanks, I missed that.