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.conf
file. - Runs in a Docker container.
- Exposes:
- Port
80
for HTTP proxy. - Port
443
for 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.crt
Run 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.conf
This 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.so
mod_proxy_html.so
mod_socache_shmcb.so
mod_proxy.so
mod_proxy_connect.so
mod_proxy_http.so
mod_ssl.so
mod_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