<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kamal Eddine Boumahdi</title>
    <description>The latest articles on DEV Community by Kamal Eddine Boumahdi (@kamaledd).</description>
    <link>https://dev.to/kamaledd</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F924467%2F90dadb58-9e99-4272-9ea7-561d79b16528.jpeg</url>
      <title>DEV Community: Kamal Eddine Boumahdi</title>
      <link>https://dev.to/kamaledd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kamaledd"/>
    <language>en</language>
    <item>
      <title>Apache forward proxy</title>
      <dc:creator>Kamal Eddine Boumahdi</dc:creator>
      <pubDate>Sun, 11 Sep 2022 16:15:16 +0000</pubDate>
      <link>https://dev.to/kamaledd/apache-forward-proxy-lfd</link>
      <guid>https://dev.to/kamaledd/apache-forward-proxy-lfd</guid>
      <description>&lt;p&gt;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.&lt;br&gt;
before we get into it I’d like to thank &lt;strong&gt;&lt;a href="https://www.youtube.com/c/CodeboardClub"&gt;Codeboard Club&lt;/a&gt;&lt;/strong&gt;, this article is inspired by their &lt;a href="https://www.youtube.com/watch?v=eshV2whJrqk&amp;amp;t=348s"&gt;video&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we’ll be using &lt;a href="https://www.apachefriends.org/"&gt;XAMPP&lt;/a&gt;, you can just &lt;a href="https://www.apachefriends.org/"&gt;download&lt;/a&gt; it, the installation process is the typical &lt;em&gt;next next install&lt;/em&gt; scenario.&lt;/p&gt;

&lt;p&gt;once installed you’ll be presented with a nice GUI like so&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--btYSNAb5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgrehzz69crjhnriffq7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--btYSNAb5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgrehzz69crjhnriffq7.png" alt="Image description" width="666" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YKpuPA4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zhu2qcx7gqqu2vcqy4yr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YKpuPA4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zhu2qcx7gqqu2vcqy4yr.png" alt="Image description" width="703" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;once done, the ❌ will be replaced by a ✅, now we can configure it by pressing the &lt;strong&gt;Config&lt;/strong&gt; button and selecting the option &lt;code&gt;Apache (httpd.conf)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z8jbZcsU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ugj49cpvc0s5u1cek49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z8jbZcsU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ugj49cpvc0s5u1cek49.png" alt="Image description" width="745" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;that will open up the file in this path &lt;code&gt;C:\xampp\apache\conf\httpd.conf&lt;/code&gt; (that is ofc if you left the installation directory as default during installation process, which defaults to &lt;code&gt;C:/&lt;/code&gt; ), 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.&lt;/p&gt;

&lt;p&gt;we will uncomment the following lines:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;LoadModule proxy_module modules/mod_proxy.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_ajp_module modules/mod_proxy_ajp.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_balancer_module modules/mod_proxy_balancer.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_connect_module modules/mod_proxy_connect.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_express_module modules/mod_proxy_express.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_ftp_module modules/mod_proxy_ftp.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_html_module modules/mod_proxy_html.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_http_module modules/mod_proxy_http.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_http2_module modules/mod_proxy_http2.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_scgi_module modules/mod_proxy_scgi.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so&lt;/code&gt;&lt;br&gt;
&lt;code&gt;LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;we will also uncomment a few other lines in a bit, but this will be enough for now, so just save and exit.&lt;/p&gt;

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

&lt;p&gt;in there we will replace this line &lt;code&gt;ServerName [www.example.com:443](http://www.example.com:443/)&lt;/code&gt; with this one &lt;code&gt;ServerName [localhost:443](http://localhost:443)&lt;/code&gt; because we don’t have a Domain name that we can associet to our proxy.&lt;/p&gt;

&lt;p&gt;now the config is almost ready, but we still need to add afew things, lets open up this file now &lt;code&gt;C:\xampp\apache\conf\extra\httpd-vhosts&lt;/code&gt;to add a proxy host,&lt;/p&gt;

&lt;p&gt;&lt;em&gt;btw you can browse to this &lt;code&gt;C:\xampp\apache\&lt;/code&gt; folder by pressing the config button and selecting the option &lt;code&gt;&amp;lt;Browse&amp;gt; [Apache]&lt;/code&gt; and click your way from there.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;to the bottom of that file you’ve fust opened add the following pack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;VirtualHost *:*&amp;gt;
    ProxyRequests On
    ProxyVia On
&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now we’ll go to the Windows control panel and search for &lt;strong&gt;internet proprieties&amp;gt;connections&amp;gt;LAN Settings&lt;/strong&gt; &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HkKgks1X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/azqsrjnp9lr2fvpnjdgb.png" alt="Image description" width="414" height="541"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0KMbA1Ey--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/42cxs4k2i6ui4otnbjqn.png" alt="Image description" width="383" height="344"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

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

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

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

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

&lt;p&gt;&lt;code&gt;LoadModule proxy_html_module modules/mod_proxy_html.so&lt;/code&gt; to load this module &lt;code&gt;proxy_html_module&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;LoadModule slotmem_shm_module modules/mod_slotmem_shm.so&lt;/code&gt; to load this module &lt;code&gt;slotmem_shm_module&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;we can now retry starting &lt;strong&gt;Apache service&lt;/strong&gt; and voilla:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yTbQ6x1b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dy78vv8us224uyq6f294.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yTbQ6x1b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dy78vv8us224uyq6f294.png" alt="Image description" width="665" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

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

</description>
    </item>
  </channel>
</rss>
