{"id":2800,"date":"2026-08-04T06:29:52","date_gmt":"2026-08-03T23:29:52","guid":{"rendered":"https:\/\/sumberlaba.com\/index.php\/2026\/08\/04\/how-to-use-nginx-as-a-reverse-proxy-a-practical-configuration-guide\/"},"modified":"2026-08-04T06:29:53","modified_gmt":"2026-08-03T23:29:53","slug":"how-to-use-nginx-as-a-reverse-proxy-a-practical-configuration-guide","status":"publish","type":"post","link":"https:\/\/sumberlaba.com\/index.php\/2026\/08\/04\/how-to-use-nginx-as-a-reverse-proxy-a-practical-configuration-guide\/","title":{"rendered":"How to Use Nginx as a Reverse Proxy: A Practical Configuration Guide"},"content":{"rendered":"<h1>How to Use Nginx as a Reverse Proxy: A Practical Configuration Guide<\/h1>\n<p>Nginx is the go-to tool for reverse proxying. It accepts client requests, forwards them to backend servers (like Node.js or Python apps), and returns the responses. This setup boosts performance, adds a security layer, and centralizes SSL handling.<\/p>\n<p>Before you begin, install Nginx and ensure you have root or sudo access. Configurations typically live in <code>\/etc\/nginx\/sites-available\/<\/code>. Let&#8217;s walk through the essentials.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/sumberlaba.com\/wp-content\/uploads\/2026\/08\/article-1785799790725.jpg\" alt=\"Article illustration\" style=\"display:block;margin:20px auto;max-width:100%;height:auto;border-radius:8px;\" \/><\/p>\n<h2>1. Basic Reverse Proxy Configuration<\/h2>\n<p>The simplest setup proxies all requests to a local backend. Add this to your server block:<\/p>\n<pre><code>location \/ {\n    proxy_pass http:\/\/127.0.0.1:3000;\n    proxy_set_header Host $host;\n    proxy_set_header X-Real-IP $remote_addr;\n}<\/code><\/pre>\n<p>After editing, run <code>nginx -t<\/code> to test and <code>systemctl reload nginx<\/code> to apply changes.<\/p>\n<h2>2. Forward Client Headers<\/h2>\n<p>Backends need the original client information. Use these headers so your app sees the real visitor IP and protocol:<\/p>\n<pre><code>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\nproxy_set_header X-Forwarded-Proto https;<\/code><\/pre>\n<p>This is essential for accurate logging and for apps that generate absolute URLs.<\/p>\n<h2>3. Load Balancing with Upstreams<\/h2>\n<pre><code>upstream backend {\n    server 10.0.0.1;\n    server 10.0.0.2;\n}\nserver {\n    location \/ {\n        proxy_pass http:\/\/backend;\n    }\n}<\/code><\/pre>\n<p>Nginx distributes requests across all servers in the upstream group. You can also add <code>weight<\/code> or <code>max_fails<\/code> parameters for more control.<\/p>\n<h2>4. WebSocket and Docker Considerations<\/h2>\n<p>If your app uses WebSockets, add <code>proxy_set_header Upgrade $http_upgrade;<\/code> and <code>Connection \"upgrade\";<\/code> to avoid broken connections. For Docker, set <code>proxy_pass http:\/\/localhost:8080<\/code> and map container ports correctly.<\/p>\n<h2>Conclusion<\/h2>\n<p>Nginx reverse proxying is straightforward once you understand the basics. Start with a simple proxy, add headers, then expand to load balancing and WebSockets as your app grows.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Use Nginx as a Reverse Proxy: A Practical Configuration Guide Nginx is the go-to tool for reverse proxying. It accepts client requests, forwards them to backend servers (like Node.js or Python apps), and returns the responses. This setup boosts performance, adds a security layer, and centralizes SSL handling. Before you begin, install Nginx &hellip; <\/p>\n","protected":false},"author":2716,"featured_media":2799,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2800","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-non-category"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/users\/2716"}],"replies":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/comments?post=2800"}],"version-history":[{"count":1,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2800\/revisions"}],"predecessor-version":[{"id":2801,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2800\/revisions\/2801"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/media\/2799"}],"wp:attachment":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/media?parent=2800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/categories?post=2800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/tags?post=2800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}