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

proxies does not work when backendUri is another port on same machine #319

Closed
johlrich opened this Issue Nov 16, 2017 · 13 comments

Comments

Projects
None yet
@johlrich

johlrich commented Nov 16, 2017

If you setup a proxies.json to point to another service running on localhost, it seems to only try and proxy to the same function app. From the outside it feels liek the proxy runtime isn't taking port into account when deciding if it's proxying to another path on the same service.

Example: if I'm running the functions cli on port 7071 and a client app on 8080. Navigating to localhost:7071/app/ will actually give back the "Your Azure Function App is up and running." placeholder page instead of the content from the other service. If I change the proxy to anything not on localhost, it will go fetch that content properly.

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "proxy-app": {
      "matchCondition": {
        "route": "/app/{*restOfPath}",
        "methods": [
          "GET"
        ]
      },
      "backendUri": "http://localhost:8080/{restOfPath}"
    }
  }
}

Using CLI 1.0.7

@DavidJFowler

This comment has been minimized.

DavidJFowler commented Dec 6, 2017

Are there any workarounds for this?

@veeshall

This comment has been minimized.

veeshall commented Dec 16, 2017

@johlrich . I am running the container @ http://192.168.99.100 - but for me the proxy isnt working even if I give an external URL. Are there any additional settings needed?

With the below proxies.json
On Azure: yyyyyy.azurewebsites.net/vGoogle --> Directs to www.google.com
On Local: http://192.168.99.100:8080/vGoogle --> 404 error
Note that http://192.168.99.100:8080 works fine, and shows up the default function app page

I also saw, there is an open issue @ Azure/app-service-announcements#68 - is this something related? If so, which versions did you use when you ran the localhost:7071?

proxies.json
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"AllTraffic": {
"matchCondition": {
"route": "{*}",
"methods": [
"GET"
]
},
"backendUri": "http://www.google.com"
}
}
}

@johlrich

This comment has been minimized.

johlrich commented Dec 16, 2017

@veeshall you need to give the route parameter a name {*} is invalid. Your proxies.json should work fine if you change it to {*everything} (or any other name)

@veeshall

This comment has been minimized.

veeshall commented Dec 16, 2017

@johlrich - sorry, might have been a copy paste error. I actually have below. But it still doesn't work on the local. Not sure if it has anything to do with not being "localhost", but an IP(?)

"route": "vGoogle",

Are you using the latest 2.0 jessie image as well? (microsoft/azure-functions-runtime:2.0.0-jessie)

@praneetloke

This comment has been minimized.

praneetloke commented Dec 20, 2017

@johlrich I have the same issue. I have an angular-cli dev server running at localhost:4200 and I can't seem to proxy anything from the functions to that. However, if I use a URL that isn't localhost, it works just fine.

To test this, I added an alias in the Windows' hosts file 127.0.0.1 and using that as the URL in my proxies.json file to proxy to my other localhost dev server. This works for me so I am going to use this as a workaround until this issue is looked into and fixed.

EDIT: Slightly out of scope for Azure Functions but if you are going to try my workaround, you will have to disable the host verification in Angular CLI for it to work. Do that at your own risk. I am running the dev server on my local machine so I am ok with it and disabled it by passing the flag --disableHostCheck true to the angular-cli.

@espray

This comment has been minimized.

espray commented Dec 25, 2017

I am not able to get even a simple proxy to work. Is there a console message if the proxy is found?

CLI - 2.0.1-beta1.15

{
  "proxies": {
    "all": {
      "matchCondition": {
        "route": "test"
      },
      "responseOverrides": {
        "response.body": "Test",
        "response.headers.Content-Type": "text/plain"
      }
    }
  }
}
@roosi

This comment has been minimized.

roosi commented Feb 21, 2018

In 2.0.1-beta.22 there is no proxy support. Any update when it will be available?

@Steven-Mark-Ford

This comment has been minimized.

Steven-Mark-Ford commented Feb 27, 2018

I'm also getting the issue: when running on localhost not being able to proxy to another port on localhost where my webapp is running.

@enrichit

This comment has been minimized.

enrichit commented May 22, 2018

Yes the lack of proxy support for version 2 is kind of a showstopper.

@JohnReeson

This comment has been minimized.

JohnReeson commented Jun 6, 2018

Hi guys, See #488 for proxy in v2

@safihamid

This comment has been minimized.

Contributor

safihamid commented Jun 6, 2018

Yes this is a separate issue. in order for this to work locally. you will need to disable proxy routing locally to the function app.
Add this app setting and everything will work:
"AZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALL": "true"

One way to add is to update your local.settings.json file.

@safihamid safihamid closed this Jun 6, 2018

@markheath

This comment has been minimized.

markheath commented Jul 4, 2018

@safihamid thanks - that got me up and running. It would be very useful for this to be mentioned in the official proxies documentation, as it took me a long time to track down why it wasn't working.

@safihamid

This comment has been minimized.

Contributor

safihamid commented Jul 5, 2018

@alexkarcher-msft would you please add this to the docs?
"AZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALL": "true"
also add this one: AZURE_FUNCTION_PROXY_BACKEND_URL_DECODE_SLASHES : true as referenced in Azure/azure-functions-host#2249

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