There are many benefits to having a reverse proxy. Some of these include but are not limited to:
- Provides a single point of access to your back-end servers
- Reduce surface attack areas
- Hide information on your back-end architecture and characteristics
- Provide SSL termination
- Remove CORs
I will elaborate more on the benefits of having a reverse proxy in a separate article as this article is focused on using Azure Function as a Proxy.
Azure functions can be used a cost effective reverse proxy. Most of my use cases of using Azure function is when a project requires integration with multiple back-end servers that needs to be accessed via single domain.
One such example of using Azure Function Proxy is in the following architecture for a Single Page Application hosted in Azure:
An Azure Function proxy for the above configuration would be something like the following:
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"website":{
"matchCondition": {
"route":"/{*url}"
},
"backendUri":"{azure_storage_domain}/website/{url}"
},
"Website-api": {
"matchCondition": {
"route": "api/{*url}"
},
"backendUri":"{azure web app domain}/{url}"
}
}
}
A sample of the above would be something like below:
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"website":{
"matchCondition": {
"route":"/{*url}"
},
"backendUri":"https://minatcoding.web.core.windows.net/website/{url}"
},
"Website-api": {
"matchCondition": {
"route": "api/{*url}"
},
"backendUri":"https://api-minat-coding.web.core.windows.net/{url}"
}
}
}
To create an Azure Function Proxy, you may refer to the following video https://www.youtube.com/watch?v=NyysLRSJUmk