= Vert.x Http Proxy
:toc: left

Vert.x Http Proxy is a reverse proxy based on Vert.x, it aims to implement reusable reverse proxy logic to focus on
higher concerns.

WARNING: This module has _Tech Preview_ status, this means the API can change between versions.

== Using Vert.x Http Proxy

To use Vert.x Http Proxy, add the following dependency to the _dependencies_ section of your build descriptor:

* Maven (in your `pom.xml`):

[source,xml,subs="+attributes"]
----
<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-http-proxy</artifactId>
  <version>${maven.version}</version>
</dependency>
----

* Gradle (in your `build.gradle` file):

[source,groovy,subs="+attributes"]
----
dependencies {
  compile 'io.vertx:vertx-http-proxy:${maven.version}'
}
----

== Basic Http Proxy

In order to accomplish a reverse proxy with Vert.x Http Proxy you need the following:

1. *Proxy Server* that handles outbound requests and forward them to the *origin server* using `HttpProxy` instance.
2. *Origin Server* that handles requests from the *proxy server* and handles responses accordingly.

Now, you have the overall concept so let's dive in implementation and begin with *origin server* then
the *proxy server* with `HttpProxy`:

== Origin Server

You simply create the *origin server* that listens to port `7070`

[source,java]
----
{@link examples.HttpProxyExamples#origin}
----

== Proxy Server With `HttpProxy`

Create the *proxy server* that listens to port `8080` with `HttpProxy` instance that handles reverse proxy logic
accordingly.

[source,java]
----
{@link examples.HttpProxyExamples#proxy}
----

Finally, all outbound requests will be forwarded as a reverse proxy to the *origin server* conveniently.
