Apache2 Https Proxy



  • Apache HttpClient Tutorial
Apache2
  • Apache HttpClient Resources

Apache SSL reverse proxy breaks Liferay Authentication. SSL setup with apache in front of tomcat. Setting up multiple ssl certificates on same server/ip on CENTOs with apache 2.2. Apache reverse proxy with SSL gives '400 bad request' Hot Network Questions. Here is what I have used to access proxy autocomplete google places requests through local host on an installation of Apache including ssl support (version 2.2 for windows). Edit the apache file httpd.conf. Setting up Apache 2 reverse proxy. Make sure that you enable the following Apache 2 modules: proxy, proxywstunnel, proxyhttp, and ssl. Create a virtual host for CODE, for example collabora.example.com, and use one of the following sample configurations. There are three possibilities: 1. SSL on both ends.

  • Selected Reading

In this chapter, we will learn how to create a HttpRequest authenticated using username and password and tunnel it through a proxy to a target host, using an example.

Step 1 - Create a CredentialsProvider object

The CredentialsProvider Interface maintains a collection to hold the user login credentials. You can create its object by instantiating the BasicCredentialsProvider class, the default implementation of this interface.

Step 2 - Set the credentials

You can set the required credentials to the CredentialsProvider object using the setCredentials() method. This method accepts two objects −

  • AuthScope object − Authentication scope specifying the details like hostname, port number, and authentication scheme name.

  • Credentials object − Specifying the credentials (username, password). Set the credentials using the setCredentials() method for both host and proxy as shown below.

Step 3 - Create an HttpClientBuilder object

Create a HttpClientBuilder using the custom() method of the HttpClients class as shown below −

Step 4 - Set the CredentialsProvider

You can set the CredentialsProvider object to a HttpClientBuilder object using the setDefaultCredentialsProvider() method. Pass the previously created CredentialsProvider object to this method.

Step 5 - Build the CloseableHttpClient

Build the CloseableHttpClient object using the build() method.

Step 6 - Create the proxy and target hosts

Create the target and proxy hosts by instantiating the HttpHost class.

Apache Proxypassreverse Https

Step 7 - Set the proxy and build a RequestConfig object

Create a RequestConfig.Builder object using the custom() method. Set the previously created proxyHost object to the RequestConfig.Builder using the setProxy() method. Finally, build the RequestConfig object using the build() method.

Step 8 - Create a HttpGet request object and set config object to it.

Create a HttpGet object by instantiating the HttpGet class. Set the config object created in the previous step to this object using the setConfig() method.

Apache Proxy Https Without Certificate

Step 9 - Execute the request

Execute the request by passing the HttpHost object (target) and request (HttpGet) as parameters to the execute() method.

Example

Apache2 Proxy Https

Following example demonstrates how to execute a HTTP request through a proxy using username and password.

Apache Https Proxy Configuration

Output

Apache2 Proxy Configuration

On executing, the above program generates the following output −