Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/relvaner/vertx-web-proxy
A proxy implementation for Vert.x ported from Smiley's HTTP-Proxy-Servlet
https://github.com/relvaner/vertx-web-proxy
java proxy reverse-proxy vertx vertx-web vertx3
Last synced: about 2 months ago
JSON representation
A proxy implementation for Vert.x ported from Smiley's HTTP-Proxy-Servlet
- Host: GitHub
- URL: https://github.com/relvaner/vertx-web-proxy
- Owner: relvaner
- License: apache-2.0
- Created: 2019-05-25T14:14:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T12:19:39.000Z (7 months ago)
- Last Synced: 2024-06-17T00:40:09.091Z (7 months ago)
- Topics: java, proxy, reverse-proxy, vertx, vertx-web, vertx3
- Language: Java
- Homepage:
- Size: 107 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
## vertx-web-proxy - Example ##
```java
ConcurrentCircuitBreakerForWebClient circuitBreaker = new ConcurrentCircuitBreakerForWebClient(vertx,
new CircuitBreakerOptions()
.setMaxFailures(5)
.setTimeout(2_000)
.setResetTimeout(30_000));public class ServerVerticle extends AbstractVerticle {
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
router.route().handler(CookieHandler.create());
router.route().handler(BodyHandler.create()
.setBodyLimit(-1)
.setHandleFileUploads(true)
.setDeleteUploadedFilesOnEnd(true)
.setMergeFormAttributes(true)
);
proxyConfig(router);
vertx.createHttpServer(new HttpServerOptions().setSsl(true).setKeyStoreOptions(
new JksOptions().setPath("server-keystore.jks").setPassword("secret")))
.requestHandler(router)
.listen(443);
}
public void proxyConfig(Router router) {
WebClientOptions options = new WebClientOptions();
options.setSsl(true);
WebClient webClient = WebClient.create(vertx, options);
ProxyWebClientOptions proxyOptions = new ProxyWebClientOptions();
proxyOptions
.setLog(true)
.setForwardIP(false);ProxyWebClient proxyWebClient = new ProxyWebClient(webClient, proxyOptions, circuitBreaker);
Map targetUris = new HashMap<>();
targetUris.put("/*", "https://host:port");
targetUris.put("/apple", "http://host:port");
targetUris.put("/banana/*", "https://host:port");
ProxyLogger.logger().setLevel(Level.INFO);
MultiProxyConfig multiProxyConfig = new MultiProxyConfig(proxyWebClient, targetUris);
multiProxyConfig.config(router);
}
}
```## License ##
This library is released under an open source Apache 2.0 license. Ported with adaptations from [Smiley's HTTP Proxy Servlet](https://github.com/mitre/HTTP-Proxy-Servlet).