<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged simple</title>
<link>https://coderlegion.com/tag/simple</link>
<description>Powered by Question2Answer</description>
<item>
<title>How to Configure Nginx as a Proxy Server?</title>
<link>https://coderlegion.com/16116/how-to-configure-nginx-as-a-proxy-server</link>
<description>
&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In previous article we could able to server simple html page.&lt;/p&gt;

&lt;p&gt;Now lets see how to use nginx as a proxy server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up a Simple Proxy Server
&lt;/h2&gt;

&lt;p&gt;One of the frequent uses of nginx is setting it up as a proxy server, which means a server that receives requests, passes them to the proxied servers, retrieves responses from them, and sends them to the clients.&lt;/p&gt;

&lt;p&gt;We will configure a basic proxy server, which serves requests on behalf of another server running in port 8080. &lt;/p&gt;

&lt;p&gt;Here is example of how to configure it.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight conf&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# This is a comment in the Main Context
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;worker_processes&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;; 

&lt;span class=&quot;n&quot;&gt;events&lt;/span&gt; { 
    &lt;span class=&quot;c&quot;&gt;# This is a simple directive inside the 'events' context
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;worker_connections&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1024&lt;/span&gt;; 
}

&lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; { 
    &lt;span class=&quot;c&quot;&gt;# We are now inside the 'http' context
&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; { 
        &lt;span class=&quot;n&quot;&gt;location&lt;/span&gt; / {
            &lt;span class=&quot;n&quot;&gt;proxy_pass&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;://&lt;span class=&quot;n&quot;&gt;localhost&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;8080&lt;/span&gt;; &lt;span class=&quot;c&quot;&gt;# Proxies traffic to the backend on 8080
&lt;/span&gt;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will be a simple server that listens on the port 8080.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add Static Files For Existing Proxy Server
&lt;/h2&gt;

&lt;p&gt;let's assume we have a static files in &lt;code&gt;/var/www/html&lt;/code&gt; directory and we want to server another application running on port 8080.&lt;/p&gt;

&lt;p&gt;so, we can configure both these in nginx it self.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight nginx&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# This is a comment in the Main Context&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;worker_processes&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 

&lt;span class=&quot;k&quot;&gt;events&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;c1&quot;&gt;# This is a simple directive inside the 'events' context&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;worker_connections&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1024&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;c1&quot;&gt;# We are now inside the 'http' context&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
        &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kn&quot;&gt;proxy_pass&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://localhost:8080&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Proxies traffic to the backend on 8080&lt;/span&gt;

        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/static/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Serves static files from /var/www/html&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way we will be able to serve both static files and other server running in port 8080.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We could able to setup simple proxy server and serve both static files and other server running on different port.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;&lt;img src=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png&quot; alt=&quot;git-lrc&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It&amp;rsquo;s online, source-available, and ready for anyone to use. &lt;br&gt;
&amp;#11088; Star it on GitHub: &lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;


</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/16116/how-to-configure-nginx-as-a-proxy-server</guid>
<pubDate>Fri, 01 May 2026 11:10:59 +0000</pubDate>
</item>
</channel>
</rss>