This project demonstrates how different HTTP clients interact with an HTTPS proxy. It sets up an Apache HTTP Server as a proxy and provides example test cases for two different HTTP clients.
-
Launches an Apache HTTP Server as a Proxy:
- Configured to act as a proxy using a provided
httpd.conffile. - Runs in a Docker container.
- Exposes:
- Port
80for HTTP proxy. - Port
443for HTTPS proxy (using a self-signed SSL certificate).
- Port
- Configured to act as a proxy using a provided
-
Includes Two Test Files:
- One for Java's built-in HTTP client.
- One for Apache HTTP client.
- Both test files demonstrate connections through HTTP and HTTPS proxy ports.
-
Simple Execution:
- The entire project, including setup and tests, can be executed with:
mvn clean test
- The entire project, including setup and tests, can be executed with:
The HTTPS proxy requires a self-signed SSL certificate. If you wish to generate your own, use the following command:
openssl req -x509 -nodes -days 1826 -newkey rsa:2048 -keyout server.key -out server.crtRun the following command to extract the default configuration from the official Apache HTTP Server Docker image:
docker run --rm httpd:2.4.59 cat /usr/local/apache2/conf/httpd.conf > httpd.confThis command creates a base configuration file named httpd.conf in your current directory.
Open the httpd.conf file and uncomment the following modules by removing the # at the beginning of their lines:
mod_xml2enc.somod_proxy_html.somod_socache_shmcb.somod_proxy.somod_proxy_connect.somod_proxy_http.somod_ssl.somod_proxy_http2.so
Uncomment the following line to include SSL-related configurations:
Include conf/extra/httpd-ssl.conf
Add the following line to enable proxy requests:
ProxyRequests On