-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1819bd5
commit 2d98976
Showing
1 changed file
with
83 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,99 @@ | ||
# AutoProxy | ||
> Proxy another api in 30 seconds from configuration | ||
# AutoProxy · [](https://www.nuget.org/packages/AutoProxy.AspNetCore) [](http://makeapullrequest.com) [](https://github.com/trenoncourt/AutoProxy/blob/master/LICENSE) [](https://www.paypal.me/trenoncourt/5) | ||
> Proxy another api in 30 seconds from configuration. | ||
AutoProxy is a drop-in microservice for proxying another api from configuration with headers forwarding, auth, cors, impersonation and more... | ||
|
||
You can also use AutoProxy as a middleware in your aspnet core app. | ||
|
||
## Installation | ||
Choose between middleware or microservice | ||
|
||
### Middleware | ||
```Powershell | ||
Install-Package AutoProxy.AspNetCore | ||
``` | ||
|
||
### Microservice | ||
Download the [last release](https://github.com/trenoncourt/AutoProxy/releases), drop it to your server and that's it! | ||
|
||
## Configuration | ||
All the configuration can be made in environment variable or appsettings.json file | ||
|
||
Just add simple json or environment based configuration like this: | ||
```json | ||
{ | ||
"BaseUrl": "http://192.168.1.42", | ||
"Cors": { | ||
"Enabled": true | ||
}, | ||
"Auth": { | ||
"Type": "ntlm", | ||
"UseImpersonation": true | ||
} | ||
"AutoProxy": { | ||
"Path": "proxy", | ||
"Proxies": [ | ||
{ | ||
"Name": "DuckDuck", // Required | ||
"BaseUrl": "https://duckduckgo.com/", // Required | ||
"Path": "proxy1", | ||
"WhiteList": "https://duckduckgo.com/api/(.*)", // Regex capable | ||
"Auth": { | ||
"Type": "Ntlm", // (Ntlm, Bearer or BasicToNtlm) | ||
"UseImpersonation": false, | ||
"User": "Jhon", | ||
"Password": "Doe", | ||
"Domain": "DoeCorp", | ||
"LogPassword": true // To log password with serilog | ||
}, | ||
"Headers": { | ||
"Remove": [ "Origin", "Host" ], | ||
"Replace": [ | ||
{ | ||
"Key": "Host", | ||
"Value": "duckduckgo.com" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
And drop the folder on your server. It can be drop in IIS, nginx and more. | ||
|
||
## Deployment | ||
Download the [last release]() and place it on your server and add your configuration. | ||
|
||
You can download previous versions [here]() | ||
You can add multiple proxies with different path, the path for the first proxy is not required. | ||
|
||
## Api configuration | ||
### Cors | ||
```json | ||
"Cors": { | ||
"Enabled": true, // default is false | ||
"Methods": "...", // default is * | ||
"Origins": "...", // default is * | ||
"Headers": "...", // default is * | ||
} | ||
``` | ||
|
||
## Configuration | ||
All the configuration can be made in environment variable or appsettings.json file : | ||
### Host | ||
Currently only chose to use IIS integration | ||
```json | ||
"Host": { | ||
"UseIis": true | ||
} | ||
``` | ||
|
||
| Name | Description | Type | Default value | | ||
| --------------------- | --------------------------------------------- | ----------- |--------------:| | ||
| **Logging** | Log settings, see aspnet core doc | Object | | | ||
| BaseUrl\* | Base url to proxy | String | | | ||
| WhiteList | List of endpoint to accept (regex capable) | String | | | ||
| **Cors** | Cors settings | Object | | | ||
| Cors.Enabled | Define if cors are enabled | Boolean | false | | ||
| Cors.Methods | Add specific methods to the policy | String | * | | ||
| Cors.Origins | Add specific origins to the policy | String | * | | ||
| Cors.Headers | Add specific headers to the policy | String | * | | ||
| Cors.Credentials | Add credentials to the policy | String | true | | ||
| **Auth** | Auth settings | Object | | | ||
| Auth.Type | (bearer or ntlm) | String | | | ||
| Auth.User | The user name for ntlm auth | String | | | ||
| Auth.Password | The password for ntlm auth | String | | | ||
| Auth.Domain | The domain for ntlm auth | String | | | ||
| Auth.UseImpersonation | True to Forward ntlm token | Boolean | false | | ||
| Auth.Token | Token for bearer auth | String | | | ||
| **Server** | Server settings | Object | | | ||
| Server.UseIIS | Enable iisIntegration | Boolean | false | | ||
| **Headers** | Headers settings | Object | | | ||
| Headers.Remove | List of headers disable in forwarding | Array | | | ||
### Kestrel | ||
Kestrel options, see [ms doc](https://docs.microsoft.com/fr-fr/dotnet/api/microsoft.aspnetcore.server.kestrel.core.kestrelserveroptions) for usage | ||
```json | ||
"Kestrel": { | ||
"AddServerHeader": false | ||
} | ||
``` | ||
|
||
Exemple of appsettings.json | ||
### Serilog | ||
storfiler use Serilog for logging, see [serilog-settings-configuration](https://github.com/serilog/serilog-settings-configuration) for usage | ||
```json | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"LogLevel": { | ||
"Default": "Warning" | ||
"Serilog": { | ||
"MinimumLevel": { | ||
"Default": "Debug", | ||
"Override": { | ||
"Microsoft": "Warning", | ||
"System": "Warning" | ||
} | ||
}, | ||
"WhiteList": "http://192.168.1.42/api/(.*)", | ||
"BaseUrl": "http://192.168.1.42", | ||
"Cors": { | ||
"Enabled": true | ||
}, | ||
"Auth": { | ||
"Type": "ntlm", | ||
"UseImpersonation": true | ||
}, | ||
"Server": { | ||
"UseIIS": true | ||
}, | ||
"Headers": { | ||
"Remove": [ | ||
"Host" | ||
] | ||
} | ||
"WriteTo": [ | ||
{ "Name": "Console" } | ||
], | ||
"Enrich": ["FromLogContext"] | ||
} | ||
``` |