DEV Community

Kamal Eddine Boumahdi
Kamal Eddine Boumahdi

Posted on

Apache forward proxy

this is a quick walkthrough setting up Apache Forward Proxy on your windows machine. I'm on windows 11, but I suppose this could still work in previous versions of windows.
before we get into it I’d like to thank Codeboard Club, this article is inspired by their video

we’ll be using XAMPP, you can just download it, the installation process is the typical next next install scenario.

once installed you’ll be presented with a nice GUI like so

Image description

as of now, we don’t have our Apache service installed, so let’s go ahead and do that by clicking the ❌ next to Apache, then confirm like so:

Image description

once done, the ❌ will be replaced by a ✅, now we can configure it by pressing the Config button and selecting the option Apache (httpd.conf)

Image description

that will open up the file in this path C:\xampp\apache\conf\httpd.conf (that is ofc if you left the installation directory as default during installation process, which defaults to C:/ ), this file is populated with config statements, notice how some lines are commented using a hash #, we will be uncommenting a few to load modules needed for enabling proxy.

we will uncomment the following lines:

LoadModule proxy_module modules/
LoadModule proxy_ajp_module modules/
LoadModule proxy_balancer_module modules/
LoadModule proxy_connect_module modules/
LoadModule proxy_express_module modules/
LoadModule proxy_fcgi_module modules/
LoadModule proxy_ftp_module modules/
LoadModule proxy_hcheck_module modules/
LoadModule proxy_html_module modules/
LoadModule proxy_http_module modules/
LoadModule proxy_http2_module modules/
LoadModule proxy_scgi_module modules/
LoadModule proxy_uwsgi_module modules/
LoadModule proxy_wstunnel_module modules/

we will also uncomment a few other lines in a bit, but this will be enough for now, so just save and exit.

we’ll also need to change the hostname setting, so go to this file C:\xampp\apache\conf\extra\httpd-ssl.conf or press the Config button again this time selecting the option Apache (httpd-ssl.conf)

in there we will replace this line ServerName []( with this one ServerName [localhost:443](http://localhost:443) because we don’t have a Domain name that we can associet to our proxy.

now the config is almost ready, but we still need to add afew things, lets open up this file now C:\xampp\apache\conf\extra\httpd-vhoststo add a proxy host,

btw you can browse to this C:\xampp\apache\ folder by pressing the config button and selecting the option <Browse> [Apache] and click your way from there.

to the bottom of that file you’ve fust opened add the following pack:

<VirtualHost *:*>
    ProxyRequests On
    ProxyVia On
Enter fullscreen mode Exit fullscreen mode

now we’ll go to the Windows control panel and search for internet proprieties>connections>LAN Settings

Image description Image description

and in the Proxy server section, set the address to [http://localhost](http://localhost) cz that’s hat we’ve set in that httpd-ssl.conf file

GUI and press start, but nothing happens, so we need to check the logs for to fegure out what’s wrong, we do that by pressing the Logs button (next to Config) and selecting the option Apache (error.log) or by directly opening the file C:\xampp\apache\logs\error.log , there (in my case at least) we find the following problems:

I18n support in mod_proxy_html requires mod_xml2enc. Without it, non-ASCII characters in proxied pages are likely to display incorrectly. and Failed to lookup provider 'shm' for 'slotmem': is mod_slotmem_shm loaded??

both of them are related to modules that are not loaded, so we’ll go back to this file C:\xampp\apache\conf\httpd.conf this time uncommenting the following lines:

LoadModule proxy_html_module modules/ to load this module proxy_html_module

LoadModule slotmem_shm_module modules/ to load this module slotmem_shm_module

we can now retry starting Apache service and voilla:

Image description

now we can surf the web a little bit, then come back and press the Logs button again this time selecting the option Apache (access.log) or by directly opening the file C:\xampp\apache\logs\access.log to see all our requests logged here because now all our they all go through the Apache Proxy Service.

Top comments (0)