New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy Pass Original Host Header to Backend #1500

Closed
chandlerkent opened this Issue May 11, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@chandlerkent

chandlerkent commented May 11, 2017

I'm experimenting with using Functions Proxies in front of some legacy applications. Those applications often use the Host header to build URLs and do redirects. Is there a way to pass the original Host header to the backend when proxying the request?

I've tried using the requestOverrides feature like:

"requestOverrides": {
	"backend.request.headers.host": "{request.headers.host}",
	"backend.request.headers.X-ORIGINAL-HOST": "{request.headers.host}"
}

The backend receives the X-ORIGINAL-HOST header correctly, but the host header is not correct.

Here's an example proxy I've set up:

https://chandler-function-proxy.azurewebsites.net/app1/

This proxies to the backend Web App http://chandler-function-proxy-app1.azurewebsites.net/app1. This is just a simple Node.js script that prints out all the headers and the URL. Notice that the X-ORIGINAL-HOST header is set correct, but the host header is:

chandler-function-proxy-app1.azurewebsites.net

instead of:

chandler-function-proxy.azurewebsites.net

Full proxies.json for posterity
{
    "$schema": "http://json.schemastore.org/proxies",
    "proxies": {
        "chandler-function-proxy-app1": {
            "matchCondition": {
                "route": "/app1"
            },
            "backendUri": "http://chandler-function-proxy-app1.azurewebsites.net/app1",
			"requestOverrides": {
				"backend.request.headers.host": "{request.headers.host}",
				"backend.request.headers.X-ORIGINAL-HOST": "{request.headers.host}"
			}
        },
        "chandler-function-proxy-app2": {
            "matchCondition": {
                "route": "/app2"
            },
            "backendUri": "http://chandler-function-proxy-app2.azurewebsites.net/app2"
        }
    }
}

@chandlerkent chandlerkent changed the title from Proxy Original Host Name to Proxy Pass Original Host Header to Backend May 12, 2017

@paulbatum

This comment has been minimized.

Show comment
Hide comment
@paulbatum

paulbatum May 19, 2017

Member

Hey @mattchenderson can you take a look a this?

Member

paulbatum commented May 19, 2017

Hey @mattchenderson can you take a look a this?

@omkarmore83

This comment has been minimized.

Show comment
Hide comment
@omkarmore83

omkarmore83 May 24, 2017

Member

Currently, we do not support overriding certain headers like Host. The behavior is to ignore such overrides. You can pass the original host as a custom header to the backend (they way you did in the example).

Member

omkarmore83 commented May 24, 2017

Currently, we do not support overriding certain headers like Host. The behavior is to ignore such overrides. You can pass the original host as a custom header to the backend (they way you did in the example).

@paulbatum

This comment has been minimized.

Show comment
Hide comment
@paulbatum

paulbatum May 30, 2017

Member

Closing as answered.

Member

paulbatum commented May 30, 2017

Closing as answered.

@paulbatum paulbatum closed this May 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment