{"id":2374,"date":"2026-07-24T00:39:49","date_gmt":"2026-07-23T17:39:49","guid":{"rendered":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/24\/how-to-set-up-nginx-as-a-reverse-proxy-a-step-by-step-guide\/"},"modified":"2026-07-24T00:39:49","modified_gmt":"2026-07-23T17:39:49","slug":"how-to-set-up-nginx-as-a-reverse-proxy-a-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/24\/how-to-set-up-nginx-as-a-reverse-proxy-a-step-by-step-guide\/","title":{"rendered":"How to Set Up Nginx as a Reverse Proxy: A Step-by-Step Guide"},"content":{"rendered":"<h1>How to Set Up Nginx as a Reverse Proxy: A Step-by-Step Guide<\/h1>\n<p>A reverse proxy sits in front of your backend servers and forwards client requests to them. Nginx is a popular, high\u2011performance choice for this task. It can balance load, cache content, and add an extra layer of security. In this guide, you\u2019ll learn the essential steps to configure Nginx as a reverse proxy.<\/p>\n<p>Before you begin, ensure Nginx is installed on your server (most Linux distributions include it in their package manager). You also need a running backend service\u2014such as a Node.js app or a Python web server\u2014that listens on a specific port, for example <code>localhost:3000<\/code>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/via.placeholder.com\/800x600\/4a90d9\/ffffff?text=how%20to%20use%20Nginx%20as%20a%20reverse%20proxy\" alt=\"Article illustration\" style=\"display:block;margin:20px auto;max-width:100%;height:auto;border-radius:8px;\" \/><\/p>\n<h2>1. Understand the Basic Reverse Proxy Directive<\/h2>\n<p>The core of Nginx reverse proxy configuration is the <code>proxy_pass<\/code> directive. It tells Nginx where to forward incoming requests. A typical block inside a <code>location<\/code> looks like this:<\/p>\n<pre><code>location \/ {\n    proxy_pass http:\/\/localhost:3000;\n}<\/code><\/pre>\n<p>This sends all requests under the root path to your backend at port 3000.<\/p>\n<h2>2. Set Up a Server Block<\/h2>\n<p>Create a new configuration file in <code>\/etc\/nginx\/sites-available\/<\/code> (or modify the default). Include a <code>server<\/code> block that listens on a port (usually 80) and specifies your domain or IP:<\/p>\n<pre><code>server {\n    listen 80;\n    server_name example.com;\n\n    location \/ {\n        proxy_pass http:\/\/localhost:3000;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n    }\n}<\/code><\/pre>\n<p>The <code>proxy_set_header<\/code> lines pass important client information to your backend.<\/p>\n<h2>3. Add Common Headers and Optimizations<\/h2>\n<p>For a production setup, include additional headers to preserve original IP addresses and support WebSockets:<\/p>\n<pre><code>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\nproxy_set_header X-Forwarded-Proto $scheme;\nproxy_http_version 1.1;\nproxy_set_header Upgrade $http_upgrade;\nproxy_set_header Connection \"upgrade\";<\/code><\/pre>\n<p>These ensure your backend receives the real client IP and protocol, and enables WebSocket connections.<\/p>\n<h2>4. Test and Reload Nginx<\/h2>\n<p>After saving the configuration, test for syntax errors:<\/p>\n<pre><code>sudo nginx -t<\/code><\/pre>\n<p>If the test passes, reload Nginx to apply changes:<\/p>\n<pre><code>sudo systemctl reload nginx<\/code><\/pre>\n<p>Now visit your server\u2019s domain or IP\u2014you should see your backend application responding.<\/p>\n<p>In a few minutes, you\u2019ve turned Nginx into a powerful reverse proxy. Experiment with load balancing and SSL termination to take full advantage of its capabilities.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Set Up Nginx as a Reverse Proxy: A Step-by-Step Guide A reverse proxy sits in front of your backend servers and forwards client requests to them. Nginx is a popular, high\u2011performance choice for this task. It can balance load, cache content, and add an extra layer of security. In this guide, you\u2019ll learn &hellip; <\/p>\n","protected":false},"author":2716,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-2374","post","type-post","status-publish","format-standard","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2374","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=2374"}],"version-history":[{"count":0,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2374\/revisions"}],"wp:attachment":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/media?parent=2374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/categories?post=2374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/tags?post=2374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}