{"id":43629,"date":"2026-09-19T14:00:04","date_gmt":"2026-09-19T07:00:04","guid":{"rendered":"https:\/\/interdata.vn\/blog\/?p=43629"},"modified":"2026-09-19T14:00:55","modified_gmt":"2026-09-19T07:00:55","slug":"cau-hinh-nginx-reverse-proxy","status":"publish","type":"post","link":"https:\/\/interdata.vn\/blog\/cau-hinh-nginx-reverse-proxy\/","title":{"rendered":"H\u01b0\u1edbng D\u1eabn C\u1ea5u H\u00ecnh Nginx Reverse Proxy Tr\u00ean Linux (Node.js, Docker v\u00e0 SSL\/HTTPS)"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"font-size: 100%;\"><strong>C\u1ea5u h\u00ecnh Nginx Reverse Proxy<\/strong> l\u00e0 vi\u1ec7c b\u1ea1n c\u1ea7n l\u00e0m khi \u0111\u00e3 deploy \u1ee9ng d\u1ee5ng Node.js, Python hay Docker l\u00ean VPS nh\u01b0ng kh\u00f4ng mu\u1ed1n m\u1edf th\u1eb3ng port n\u1ed9i b\u1ed9 ra Internet. Thay v\u00ec \u0111\u1ec3 ng\u01b0\u1eddi d\u00f9ng truy c\u1eadp <code>IP:3000<\/code>, b\u1ea1n cho h\u1ecd v\u00e0o domain qua port 80\/443, c\u00f2n Nginx \u0111\u1ee9ng gi\u1eefa chuy\u1ec3n ti\u1ebfp request v\u00e0o backend. \u1ede h\u01b0\u1edbng d\u1eabn n\u00e0y, <a href=\"\/\"><strong>InterData<\/strong><\/a> s\u1ebd \u0111i t\u1eeb c\u00e0i \u0111\u1eb7t, vi\u1ebft file config, th\u00eam SSL, \u0111\u1ebfn x\u1eed l\u00fd l\u1ed7i 502 v\u00e0 504 tr\u00ean Ubuntu, Debian, CentOS, AlmaLinux v\u00e0 Rocky Linux.<\/span><\/p>\n<div style=\"background-color: #eff6ff; padding: 20px; border: 1.5px solid #BFDBFE; border-radius: 12px; margin-bottom: 40px; box-shadow: 0 8px 20px rgba(37,99,235,0.05);\">\n<p style=\"font-family: 'Be Vietnam Pro', sans-serif; font-weight: bold; font-size: 18px; margin: 0 0 15px; color: #1e3a8a;\">N\u1ed8I DUNG B\u00c0I VI\u1ebeT<\/p>\n<ul style=\"list-style-type: none; padding-left: 0; margin: 0;\">\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section1\">Nginx Reverse Proxy l\u00e0 g\u00ec? T\u1ea1i sao c\u1ea7n c\u1ea5u h\u00ecnh?<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section2\">So s\u00e1nh Nginx v\u1edbi c\u00e1c Reverse Proxy ph\u1ed5 bi\u1ebfn kh\u00e1c<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section3\">C\u1ea5u h\u00ecnh Nginx Reverse Proxy tr\u00ean Ubuntu \/ Debian<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section4\">C\u1ea5u h\u00ecnh Nginx Reverse Proxy tr\u00ean CentOS \/ AlmaLinux \/ Rocky Linux<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section5\">Use case 1: Nginx Reverse Proxy cho Node.js v\u00e0 Python<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section6\">Use case 2: Nginx Reverse Proxy cho Docker Container<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section7\">Th\u00eam SSL\/HTTPS v\u00e0 b\u1ea3o m\u1eadt n\u00e2ng cao<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section8\">X\u1eed l\u00fd l\u1ed7i th\u01b0\u1eddng g\u1eb7p khi c\u1ea5u h\u00ecnh Nginx Reverse Proxy<\/a><\/li>\n<\/ul>\n<\/div>\n\n\n<style>\n.interdata-plan-carousel,.interdata-plan-carousel *{box-sizing:border-box}\n.interdata-plan-carousel{--blue:#005bea;--blue-dark:#004dcc;--text:#071832;--muted:#516173;--border:#d8e6fb;--bg:#f3f8ff;--shadow:0 5px 14px rgba(0,62,145,.08);background:var(--bg);padding:14px 56px 18px;position:relative;overflow:hidden;border-radius:20px;}\n.interdata-carousel-heading{color:#f00;font-family:Roboto,sans-serif;font-size:18px;line-height:1.35;font-weight:800;text-align:center;margin:0 0 14px}\n.interdata-plan-viewport{overflow:hidden;width:100%}\n.interdata-plan-track{display:flex;align-items:stretch;gap:12px;overflow:visible;padding:0 0 4px;transform:translate3d(0,0,0);transition:transform .45s ease;will-change:transform;touch-action:pan-y}\n.interdata-plan-card{flex:0 0 calc((100% - 24px)\/3);min-width:0;min-height:0!important;height:auto;background:#fff;border:1px solid var(--border);border-radius:8px;padding:15px 12px 13px;display:flex;flex-direction:column;box-shadow:var(--shadow)}\n.interdata-plan-title{color:var(--blue-dark);font-size:16px;line-height:1.22;font-weight:800;text-align:center;margin:0 0 7px;text-transform:uppercase;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.interdata-plan-price{color:var(--blue-dark);font-size:24px;line-height:1;font-weight:900;text-align:center;margin-bottom:12px;white-space:nowrap;letter-spacing:0}\n.interdata-plan-price span{font-size:10px;font-weight:800;margin-left:2px}\n.interdata-plan-badge{align-self:center;display:inline-flex;align-items:center;justify-content:center;background:#ff3934;color:#fff;border-radius:5px;padding:7px 8px;font-size:9px;line-height:1;font-weight:800;margin-bottom:15px;white-space:nowrap;max-width:100%}\n.interdata-plan-features{list-style:none!important;padding:0!important;margin:0!important}\n.interdata-plan-features li{display:flex;gap:7px;align-items:flex-start;color:var(--text);font-size:12px;line-height:1.35;font-weight:700;text-align:left;margin:0 0 10px!important;padding:0!important}\n.interdata-plan-icon{width:14px;min-width:14px;height:14px;color:#0069ff;margin-top:2px}\n.interdata-plan-icon svg{display:block;width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}\n.interdata-plan-spacer{flex:1;min-height:16px}\n.interdata-plan-button{display:flex;align-items:center;justify-content:center;min-height:42px;width:100%;margin-top:auto!important;margin-bottom:0!important;background:var(--blue);color:#fff!important;border-radius:5px;font-size:13px;font-weight:800;text-decoration:none!important;box-shadow:0 7px 14px rgba(0,91,234,.24);transition:transform .2s ease,background .2s ease}\n.interdata-plan-button:hover{background:var(--blue-dark);color:#fff!important;transform:translateY(-1px)}\n.interdata-carousel-arrow{position:absolute;top:50%;z-index:5;width:44px;height:54px;border:2px solid #fff!important;border-radius:999px;background:var(--blue)!important;color:#fff!important;box-shadow:0 8px 22px rgba(0,62,145,.32);display:flex!important;align-items:center;justify-content:center;cursor:pointer;transform:translateY(-35%);transition:background .2s ease,color .2s ease,opacity .2s ease,transform .2s ease}\n.interdata-carousel-arrow:hover{background:var(--blue-dark)!important;color:#fff!important;transform:translateY(-35%) scale(1.04)}\n.interdata-carousel-arrow:disabled{opacity:.78;cursor:not-allowed;background:#8aa6cf!important;color:#fff!important}\n.interdata-carousel-arrow:disabled:hover{background:#8aa6cf!important;color:#fff!important;transform:translateY(-35%)}\n.interdata-carousel-arrow svg{display:none!important}\n.interdata-carousel-arrow:before{content:none!important;display:none!important}\n.interdata-carousel-mark{display:block!important;color:#fff!important;font-family:Arial,Helvetica,sans-serif!important;font-size:38px!important;font-weight:900!important;line-height:1!important;text-align:center!important;pointer-events:none!important;transform:translateY(-2px)}\n.interdata-carousel-prev{left:14px}\n.interdata-carousel-prev .interdata-carousel-mark{margin-left:-2px}\n.interdata-carousel-next{right:14px}\n.interdata-carousel-next .interdata-carousel-mark{margin-right:-2px}\n@media (max-width:800px){.interdata-plan-carousel{padding:12px 44px 16px}.interdata-plan-card{flex-basis:calc((100% - 12px)\/2)}.interdata-carousel-heading{font-size:16px}.interdata-carousel-prev{left:6px}.interdata-carousel-next{right:6px}}\n@media (max-width:480px){.interdata-plan-carousel{padding:12px 38px 16px}.interdata-plan-card{flex-basis:100%}.interdata-plan-price{font-size:23px}.interdata-carousel-arrow{width:34px;height:44px}.interdata-carousel-mark{font-size:32px!important}.interdata-carousel-prev{left:3px}.interdata-carousel-next{right:3px}}\n<\/style>\n\n<div class=\"interdata-plan-carousel\" data-interdata-carousel>\n  <div class=\"interdata-carousel-heading\">Si\u00eau \u01afu \u0110\u00e3i VPS \/ CLOUD SERVER - Ti\u1ebft Ki\u1ec7m \u0110\u1ebfn 70%<\/div>\n\n  <svg width=\"0\" height=\"0\" style=\"position:absolute;visibility:hidden\" aria-hidden=\"true\">\n    <symbol id=\"id-icon-cpu\" viewBox=\"0 0 24 24\"><rect x=\"7\" y=\"7\" width=\"10\" height=\"10\" rx=\"2\"><\/rect><path d=\"M4 9h3M4 15h3M17 9h3M17 15h3M9 4v3M15 4v3M9 17v3M15 17v3\"><\/path><path d=\"M10 10h4v4h-4z\"><\/path><\/symbol>\n    <symbol id=\"id-icon-ram\" viewBox=\"0 0 24 24\"><rect x=\"4\" y=\"8\" width=\"16\" height=\"8\" rx=\"2\"><\/rect><path d=\"M7 16v2M11 16v2M15 16v2M19 16v2M7 11h1M11 11h1M15 11h1\"><\/path><\/symbol>\n    <symbol id=\"id-icon-storage\" viewBox=\"0 0 24 24\"><rect x=\"6\" y=\"3\" width=\"12\" height=\"18\" rx=\"2\"><\/rect><path d=\"M9 7h6\"><\/path><circle cx=\"12\" cy=\"16\" r=\"1.5\"><\/circle><\/symbol>\n    <symbol id=\"id-icon-network\" viewBox=\"0 0 24 24\"><path d=\"M5 12.5a10 10 0 0 1 14 0\"><\/path><path d=\"M8.5 16a5 5 0 0 1 7 0\"><\/path><path d=\"M12 19h.01\"><\/path><\/symbol>\n    <symbol id=\"id-icon-gift\" viewBox=\"0 0 24 24\"><rect x=\"3\" y=\"8\" width=\"18\" height=\"13\" rx=\"2\"><\/rect><path d=\"M12 8v13M3 12h18\"><\/path><path d=\"M7.5 8C6.1 8 5 6.9 5 5.5S6.1 3 7.5 3C10 3 12 8 12 8\"><\/path><path d=\"M16.5 8C17.9 8 19 6.9 19 5.5S17.9 3 16.5 3C14 3 12 8 12 8\"><\/path><\/symbol>\n  <\/svg>\n\n  <button class=\"interdata-carousel-arrow interdata-carousel-prev\" type=\"button\" aria-label=\"Xem 3 g\u00f3i tr\u01b0\u1edbc\" onclick=\"var r=this.closest('[data-interdata-carousel]');if(!r)return false;var t=r.querySelector('.interdata-plan-track'),c=t?t.querySelectorAll('.interdata-plan-card'):[];if(!t||!c.length)return false;var v=window.matchMedia('(max-width:480px)').matches?1:(window.matchMedia('(max-width:800px)').matches?2:3),m=Math.max(0,c.length-Math.min(v,c.length||1)),s=[],i=0;while(i&lt;m){s.push(i);i+=v}if(!s.length||s[s.length-1]!==m)s.push(m);var p=parseInt(r.getAttribute('data-inline-page')||'0',10);p=(p-1+s.length)%s.length;r.setAttribute('data-inline-page',p);var g=parseFloat(window.getComputedStyle(t).gap)||12,w=c[0].getBoundingClientRect().width;t.style.transition='transform .45s ease';t.style.transform='translate3d('+(-(w+g)*s[p])+'px,0,0)';return false;\">\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M15 18l-6-6 6-6\"><\/path><\/svg>\n    <span class=\"interdata-carousel-mark\" aria-hidden=\"true\">&#8249;<\/span>\n  <\/button>\n\n  <div class=\"interdata-plan-viewport\">\n    <div class=\"interdata-plan-track\">\n      <!-- 7 card d\u1ef1 ph\u00f2ng: JavaScript s\u1ebd \u0111\u1ed3ng b\u1ed9 l\u1ea1i t\u1eeb API portal khi trang t\u1ea3i. -->\n      <article class=\"interdata-plan-card\" data-plan-pid=\"490\">\n        <h3 class=\"interdata-plan-title\">Premium Base<\/h3>\n        <div class=\"interdata-plan-price\">299.000 \u0111<span>\/3 th\u00e1ng<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>2 vCore Intel Xeon Scalable<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>2 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>30 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/best-value-plans-2026\/best-value-plans-premium-base\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"529\">\n        <h3 class=\"interdata-plan-title\">INTER PLATINUM 1<\/h3>\n        <div class=\"interdata-plan-price\">998.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>2 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>3 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>30 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/inter-platinum-series-2026\/inter-platinum-1\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"530\">\n        <h3 class=\"interdata-plan-title\">INTER PLATINUM 2<\/h3>\n        <div class=\"interdata-plan-price\">2.666.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>5 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>8 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>70 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/inter-platinum-series-2026\/inter-platinum-2\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"531\">\n        <h3 class=\"interdata-plan-title\">INTER PLATINUM 3<\/h3>\n        <div class=\"interdata-plan-price\">5.888.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>9 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>16 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>140 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/inter-platinum-series-2026\/inter-platinum-3\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"521\">\n        <h3 class=\"interdata-plan-title\">BD-Cloud 1<\/h3>\n        <div class=\"interdata-plan-price\">988.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>3 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>3 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>30 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/best-plan-real-cloud\/bd-cloud-1\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"522\">\n        <h3 class=\"interdata-plan-title\">BD-Cloud 2<\/h3>\n        <div class=\"interdata-plan-price\">2.988.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>4 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>8 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>80 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300 Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/best-plan-real-cloud\/bd-cloud-2\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"523\">\n        <h3 class=\"interdata-plan-title\">BD-Cloud 3<\/h3>\n        <div class=\"interdata-plan-price\">5.999.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>8 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>16 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>140 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>400 Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/best-plan-real-cloud\/bd-cloud-3\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n    <\/div>\n  <\/div>\n\n  <button class=\"interdata-carousel-arrow interdata-carousel-next\" type=\"button\" aria-label=\"Xem 3 g\u00f3i ti\u1ebfp theo\" onclick=\"var r=this.closest('[data-interdata-carousel]');if(!r)return false;var t=r.querySelector('.interdata-plan-track'),c=t?t.querySelectorAll('.interdata-plan-card'):[];if(!t||!c.length)return false;var v=window.matchMedia('(max-width:480px)').matches?1:(window.matchMedia('(max-width:800px)').matches?2:3),m=Math.max(0,c.length-Math.min(v,c.length||1)),s=[],i=0;while(i&lt;m){s.push(i);i+=v}if(!s.length||s[s.length-1]!==m)s.push(m);var p=parseInt(r.getAttribute('data-inline-page')||'0',10);p=(p+1)%s.length;r.setAttribute('data-inline-page',p);var g=parseFloat(window.getComputedStyle(t).gap)||12,w=c[0].getBoundingClientRect().width;t.style.transition='transform .45s ease';t.style.transform='translate3d('+(-(w+g)*s[p])+'px,0,0)';return false;\">\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 18l6-6-6-6\"><\/path><\/svg>\n    <span class=\"interdata-carousel-mark\" aria-hidden=\"true\">&#8250;<\/span>\n  <\/button>\n<\/div>\n\n<script>\n(function(){\n  var API_GROUPS=[\n    {url:'https:\/\/support.interdata.vn\/packages.php?gid=89&module',pids:[490]},\n    {url:'https:\/\/support.interdata.vn\/packages.php?gid=100&module',pids:[529,530,531]},\n    {url:'https:\/\/support.interdata.vn\/packages.php?gid=97&module',pids:[521,522,523]}\n  ];\n  var PLAN_CYCLES={\n    490:{key:'quarterly',label:'3 th\u00e1ng'},\n    529:{key:'annually',label:'n\u0103m'},\n    530:{key:'annually',label:'n\u0103m'},\n    531:{key:'annually',label:'n\u0103m'},\n    521:{key:'annually',label:'n\u0103m'},\n    522:{key:'annually',label:'n\u0103m'},\n    523:{key:'annually',label:'n\u0103m'}\n  };\n\n  function fetchPlanData(){\n    if(window.interdataPlanApiPromise)return window.interdataPlanApiPromise;\n\n    window.interdataPlanApiPromise=Promise.all(API_GROUPS.map(function(group){\n      return fetch(group.url,{method:'GET',mode:'cors',cache:'no-store'})\n        .then(function(response){\n          if(!response.ok)throw new Error('API '+response.status);\n          return response.json();\n        })\n        .then(function(data){\n          if(!data||data.success!==true||!Array.isArray(data.products))return [];\n          return data.products.filter(function(product){\n            return group.pids.indexOf(Number(product.pid))!==-1;\n          });\n        })\n        .catch(function(error){\n          console.warn('Kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt nh\u00f3m g\u00f3i InterData:',group.url,error);\n          return [];\n        });\n    })).then(function(groups){\n      return groups.reduce(function(all,products){return all.concat(products);},[]);\n    });\n\n    return window.interdataPlanApiPromise;\n  }\n\n  function parseDescription(html){\n    var source=String(html||'')\n      .replace(\/<brs*\/?>\/gi,'n')\n      .replace(\/<\/(p|div|li)>\/gi,'n');\n    var holder=document.createElement('div');\n    holder.innerHTML=source;\n    var strong=holder.querySelector('strong');\n    var badge=strong?strong.textContent.trim():'';\n    var lines=(holder.textContent||'').split(\/r?n\/).map(function(line){\n      return line.trim();\n    }).filter(Boolean);\n    if(badge&&lines[0]===badge)lines.shift();\n    return {badge:badge,features:lines};\n  }\n\n  function iconForFeature(feature){\n    if(\/ram\/i.test(feature))return 'id-icon-ram';\n    if(\/ssd|nvme|storage|disk\/i.test(feature))return 'id-icon-storage';\n    if(\/vcore|vcpu|cpu|xeon|amd\/i.test(feature))return 'id-icon-cpu';\n    if(\/ipv4|network|mbps|gbps|bandwidth\/i.test(feature))return 'id-icon-network';\n    return 'id-icon-gift';\n  }\n\n  function createFeatureItem(feature){\n    var item=document.createElement('li');\n    var icon=document.createElement('span');\n    var svg=document.createElementNS('http:\/\/www.w3.org\/2000\/svg','svg');\n    var use=document.createElementNS('http:\/\/www.w3.org\/2000\/svg','use');\n    icon.className='interdata-plan-icon';\n    use.setAttribute('href','#'+iconForFeature(feature));\n    svg.appendChild(use);\n    icon.appendChild(svg);\n    item.appendChild(icon);\n    item.appendChild(document.createTextNode(feature));\n    return item;\n  }\n\n  function updateCardFromApi(root,product){\n    var pid=Number(product.pid);\n    var cycle=PLAN_CYCLES[pid];\n    var card=root.querySelector('[data-plan-pid=\"'+pid+'\"]');\n    if(!card||!cycle)return;\n\n    var title=card.querySelector('.interdata-plan-title');\n    var priceBox=card.querySelector('.interdata-plan-price');\n    var badgeBox=card.querySelector('.interdata-plan-badge');\n    var featureList=card.querySelector('.interdata-plan-features');\n    var button=card.querySelector('.interdata-plan-button');\n    var description=parseDescription(product.description);\n    var pricing=product.pricing&&product.pricing.VND;\n    var price=pricing?Number(pricing[cycle.key]):-1;\n\n    if(title&&product.name)title.textContent=product.name;\n    if(priceBox&&Number.isFinite(price)&&price>=0){\n      priceBox.textContent=Math.round(price).toLocaleString('vi-VN')+' \u0111';\n      var suffix=document.createElement('span');\n      suffix.textContent='\/'+cycle.label;\n      priceBox.appendChild(suffix);\n    }\n    if(badgeBox&&description.badge)badgeBox.textContent=description.badge;\n    if(featureList&&description.features.length){\n      featureList.textContent='';\n      description.features.forEach(function(feature){\n        featureList.appendChild(createFeatureItem(feature));\n      });\n    }\n    if(button&&product.product_url)button.href=product.product_url;\n  }\n\n  function setupInterDataCarousel(root){\n    var track=root.querySelector('.interdata-plan-track');\n    var prev=root.querySelector('.interdata-carousel-prev');\n    var next=root.querySelector('.interdata-carousel-next');\n    if(!track||!prev||!next||track.dataset.ready==='1')return;\n    track.dataset.ready='1';\n    prev.disabled=false;\n    next.disabled=false;\n    var activePage=0;\n    var touchStartX=null;\n\n    function visibleCards(){\n      if(window.matchMedia&&window.matchMedia('(max-width:480px)').matches)return 1;\n      if(window.matchMedia&&window.matchMedia('(max-width:800px)').matches)return 2;\n      return 3;\n    }\n\n    function pageStarts(){\n      var total=track.querySelectorAll('.interdata-plan-card').length;\n      var visible=Math.min(visibleCards(),total||1);\n      var maxStart=Math.max(0,total-visible);\n      var starts=[];\n      var start=0;\n      while(start<maxStart){\n        starts.push(start);\n        start+=visible;\n      }\n      if(!starts.length||starts[starts.length-1]!==maxStart)starts.push(maxStart);\n      return starts;\n    }\n\n    function renderSlide(animate){\n      var cards=track.querySelectorAll('.interdata-plan-card');\n      var starts=pageStarts();\n      if(!cards.length||!starts.length)return;\n      if(activePage>=starts.length)activePage=starts.length-1;\n      if(activePage<0)activePage=0;\n\n      var cardWidth=cards[0].getBoundingClientRect().width;\n      var trackStyle=window.getComputedStyle?window.getComputedStyle(track):null;\n      var gap=trackStyle?parseFloat(trackStyle.columnGap||trackStyle.gap):12;\n      if(!Number.isFinite(gap))gap=12;\n      if(cardWidth<=0)return;\n\n      track.style.transition=animate?'transform .45s ease':'none';\n      track.style.transform='translate3d('+(-(cardWidth+gap)*starts[activePage])+'px,0,0)';\n      prev.setAttribute('aria-disabled',starts.length>1?'false':'true');\n      next.setAttribute('aria-disabled',starts.length>1?'false':'true');\n    }\n\n    function move(direction){\n      var starts=pageStarts();\n      if(starts.length<=1)return;\n      activePage=parseInt(root.getAttribute('data-inline-page')||activePage,10)||0;\n      activePage=(activePage+direction+starts.length)%starts.length;\n      root.setAttribute('data-inline-page',activePage);\n      renderSlide(true);\n    }\n\n    track.addEventListener('touchstart',function(event){\n      touchStartX=event.touches&&event.touches[0]?event.touches[0].clientX:null;\n    },{passive:true});\n    track.addEventListener('touchend',function(event){\n      if(touchStartX===null)return;\n      var endX=event.changedTouches&&event.changedTouches[0]?event.changedTouches[0].clientX:touchStartX;\n      var distance=endX-touchStartX;\n      touchStartX=null;\n      if(Math.abs(distance)>=40)move(distance<0?1:-1);\n    },{passive:true});\n\n    function resetAfterResize(){\n      activePage=0;\n      root.setAttribute('data-inline-page','0');\n      renderSlide(false);\n    }\n\n    window.addEventListener('resize',resetAfterResize);\n    window.addEventListener('load',resetAfterResize);\n    if('ResizeObserver' in window){\n      var resizeObserver=new ResizeObserver(function(){renderSlide(false);});\n      resizeObserver.observe(root);\n    }\n    window.requestAnimationFrame(function(){renderSlide(false);});\n    window.setTimeout(function(){renderSlide(false);},250);\n    window.setTimeout(function(){renderSlide(false);},1000);\n\n    fetchPlanData().then(function(products){\n      products.forEach(function(product){updateCardFromApi(root,product);});\n      renderSlide(false);\n    });\n  }\n\n  function initInterDataCarousels(){\n    document.querySelectorAll('[data-interdata-carousel]').forEach(setupInterDataCarousel);\n  }\n\n  if(document.readyState==='loading'){\n    document.addEventListener('DOMContentLoaded',initInterDataCarousels);\n  }else{\n    initInterDataCarousels();\n  }\n\n  if('MutationObserver' in window){\n    var initQueued=false;\n    new MutationObserver(function(){\n      if(initQueued)return;\n      initQueued=true;\n      window.requestAnimationFrame(function(){\n        initQueued=false;\n        initInterDataCarousels();\n      });\n    }).observe(document.documentElement,{childList:true,subtree:true});\n  }\n})();\n<\/script>\n\n\t<div id=\"gap-457887941\" class=\"gap-element clearfix\" style=\"display:block; height:auto;\">\n\t\t\n<style>\n#gap-457887941 {\n  padding-top: 15px;\n}\n<\/style>\n\t<\/div>\n\t\n<h2 id=\"section1\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">Nginx Reverse Proxy l\u00e0 g\u00ec? T\u1ea1i sao c\u1ea7n c\u1ea5u h\u00ecnh?<\/h2>\n<p style=\"text-align: justify;\">Hi\u1ec3u \u0111\u01a1n gi\u1ea3n, Nginx Reverse Proxy l\u00e0 c\u00e1ch b\u1ea1n \u0111\u1eb7t Nginx ng\u1ed3i tr\u01b0\u1edbc \u1ee9ng d\u1ee5ng. Client g\u00f5 domain, request ch\u1ea1m v\u00e0o Nginx tr\u01b0\u1edbc, r\u1ed3i Nginx m\u1edbi chuy\u1ec3n ti\u1ebfp v\u00e0o backend \u0111ang ch\u1ea1y \u1edf port 3000, 8000 hay 8080. Backend kh\u00f4ng bao gi\u1edd l\u1ed9 tr\u1ef1c ti\u1ebfp ra ngo\u00e0i. N\u1ebfu mu\u1ed1n n\u1eafm r\u00f5 ki\u1ebfn tr\u00fac event-driven c\u1ee7a Nginx, b\u1ea1n \u0111\u1ecdc th\u00eam b\u00e0i <a href=\"https:\/\/interdata.vn\/blog\/nginx-la-gi\/\">Nginx l\u00e0 g\u00ec<\/a>. C\u00f2n kh\u00e1i ni\u1ec7m proxy \u0111\u1ea3o chi\u1ec1u n\u00f3i chung \u0111\u01b0\u1ee3c gi\u1ea3i th\u00edch \u1edf b\u00e0i <a href=\"https:\/\/interdata.vn\/blog\/reverse-proxy-la-gi\/\">Reverse Proxy l\u00e0 g\u00ec<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-43638\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Nginx-Reverse-Proxy.jpg\" alt=\"Nginx Reverse Proxy\" width=\"800\" height=\"534\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Nginx-Reverse-Proxy.jpg 1050w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Nginx-Reverse-Proxy-300x200.jpg 300w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Nginx-Reverse-Proxy-1024x684.jpg 1024w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Nginx-Reverse-Proxy-768x513.jpg 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">Reverse Proxy kh\u00e1c g\u00ec Forward Proxy?<\/h3>\n<p style=\"text-align: justify;\">Forward Proxy \u0111\u1ea1i di\u1ec7n cho client \u0111i ra Internet. V\u00ed d\u1ee5 \u0111i\u1ec3n h\u00ecnh l\u00e0 VPN c\u00f4ng ty ho\u1eb7c proxy c\u1ee7a tr\u01b0\u1eddng h\u1ecdc. Reverse Proxy l\u00e0m ng\u01b0\u1ee3c l\u1ea1i: n\u00f3 \u0111\u1ea1i di\u1ec7n cho server, \u0111\u1ee9ng tr\u01b0\u1edbc backend, v\u00e0 client kh\u00f4ng h\u1ec1 bi\u1ebft backend th\u1eadt n\u1eb1m \u1edf \u0111\u00e2u. G\u1ea7n nh\u01b0 m\u1ecdi h\u1ec7 th\u1ed1ng web production \u0111\u1ec1u d\u00f9ng m\u00f4 h\u00ecnh reverse proxy v\u00ec n\u00f3 gom SSL, logging, caching v\u00e0 rate limiting v\u1ec1 m\u1ed9t ch\u1ed7.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">T\u1ea1i sao kh\u00f4ng m\u1edf th\u1eb3ng port \u1ee9ng d\u1ee5ng ra Internet?<\/h3>\n<p style=\"text-align: justify;\">Khi b\u1ea1n ch\u1ea1y <code>node app.js<\/code> v\u00e0 bind v\u00e0o <code>0.0.0.0:3000<\/code>, b\u1ea5t k\u1ef3 ai qu\u00e9t port \u0111\u1ec1u c\u00f3 th\u1ec3 ch\u1ea1m t\u1edbi \u1ee9ng d\u1ee5ng. \u0110\u1eb7t Nginx l\u00ean tr\u01b0\u1edbc gi\u1ea3i quy\u1ebft chuy\u1ec7n \u0111\u00f3: ch\u1ec9 port 80 v\u00e0 443 m\u1edf ra ngo\u00e0i, backend bind v\u00e0o <code>127.0.0.1:3000<\/code>, t\u1ee9c ch\u1ec9 Nginx tr\u00ean c\u00f9ng m\u00e1y g\u1ecdi \u0111\u01b0\u1ee3c. B\u1ed1n l\u1ee3i \u00edch th\u1ef1c t\u1ebf m\u00e0 b\u1ea1n s\u1ebd th\u1ea5y ngay:<\/p>\n<ul>\n<li>\u1ea8n IP v\u00e0 port backend, gi\u1ea3m b\u1ec1 m\u1eb7t t\u1ea5n c\u00f4ng. K\u1ebft h\u1ee3p UFW ho\u1eb7c firewalld ch\u1eb7n h\u1ebft port n\u1ed9i b\u1ed9 t\u1eeb b\u00ean ngo\u00e0i.<\/li>\n<li>Ch\u1ec9 c\u1ea7n c\u00e0i ch\u1ee9ng ch\u1ec9 Let&#8217;s Encrypt m\u1ed9t l\u1ea7n tr\u00ean Nginx. Backend kh\u00f4ng ph\u1ea3i x\u1eed l\u00fd TLS.<\/li>\n<li>Ph\u00e2n ph\u1ed1i request \u0111\u1ebfn nhi\u1ec1u instance backend qua block <code>upstream<\/code> khi traffic t\u0103ng.<\/li>\n<li>Nhi\u1ec1u domain ho\u1eb7c nhi\u1ec1u app ch\u1ea1y c\u00f9ng VPS \u0111\u1ec1u \u0111i qua port 80\/443, kh\u00f4ng c\u1ea7n m\u1edf th\u00eam port n\u00e0o.<\/li>\n<\/ul>\n<div style=\"display: flex; flex-wrap: wrap; background-color: #fff; border: 1.5px solid #BFDBFE; box-shadow: 0 8px 20px rgba(37,99,235,0.08); border-radius: 12px; overflow: hidden; margin: 35px 0;\">\n<div style=\"flex: 1; min-width: 250px; background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%); display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center;\">\n<div>\n<p style=\"color: #fff; font-size: 34px; font-family: 'Be Vietnam Pro', sans-serif; font-weight: bold; margin: 0; line-height: 1.1;\">Thu\u00ea VPS InterData<\/p>\n<p style=\"color: #dbeafe; font-size: 15px; font-weight: 600; margin-top: 12px;\">CPU th\u1ebf h\u1ec7 m\u1edbi, SSD NVMe U.2, h\u1ed7 tr\u1ee3 k\u1ef9 thu\u1eadt 24\/7<\/p>\n<\/div>\n<\/div>\n<div style=\"flex: 2; padding: 25px; min-width: 300px;\">\n<h3 style=\"font-family: 'Be Vietnam Pro', sans-serif; color: #1e3a8a; margin-top: 0; font-size: 20px;\">C\u1ea7n VPS Linux c\u00f3 quy\u1ec1n root \u0111\u1ec3 c\u00e0i Nginx v\u00e0 th\u1ef1c h\u00e0nh ngay?<\/h3>\n<p style=\"text-align: justify; font-size: 15px; margin-bottom: 15px;\">VPS InterData ch\u1ea1y Ubuntu, Debian ho\u1eb7c CentOS v\u1edbi quy\u1ec1n root \u0111\u1ea7y \u0111\u1ee7 \u0111\u1ec3 b\u1ea1n c\u00e0i Nginx, t\u1ea1o file config, ch\u1ea1y <code>systemctl reload nginx<\/code> v\u00e0 deploy Node.js ho\u1eb7c Docker \u0111\u00fang nh\u01b0 h\u01b0\u1edbng d\u1eabn trong b\u00e0i. \u1ed4 c\u1ee9ng NVMe U.2, c\u00f3 backup \u0111\u1ecbnh k\u1ef3 v\u00e0 b\u1ea3o v\u1ec7 DDoS.<\/p>\n<p><a style=\"background: linear-gradient(90deg, #2563EB 0%, #1E3A8A 100%); color: #fff; padding: 12px 25px; text-decoration: none; font-weight: 600; border-radius: 8px; font-size: 15px; display: inline-block; box-shadow: 0 5px 15px rgba(37,99,235,0.3);\" href=\"https:\/\/interdata.vn\/thue-vps\/\" target=\"_blank\" rel=\"noopener\">Xem B\u1ea3ng Gi\u00e1 Thu\u00ea VPS \u27f6<\/a><\/p>\n<\/div>\n<\/div>\n<h2 id=\"section2\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">So s\u00e1nh Nginx v\u1edbi c\u00e1c Reverse Proxy ph\u1ed5 bi\u1ebfn kh\u00e1c<\/h2>\n<p style=\"text-align: justify;\">N\u0103m c\u00f4ng c\u1ee5 d\u01b0\u1edbi \u0111\u00e2y \u0111\u1ec1u l\u00e0m \u0111\u01b0\u1ee3c reverse proxy, nh\u01b0ng m\u1ed7i c\u00e1i c\u00f3 ch\u1ed7 m\u1ea1nh ri\u00eang. B\u1ea3ng n\u00e0y d\u1ef1a tr\u00ean t\u00e0i li\u1ec7u ch\u00ednh th\u1ee9c v\u00e0 tr\u1ea3i nghi\u1ec7m ch\u1ea1y th\u1ef1c t\u1ebf tr\u00ean VPS. N\u1ebfu b\u1ea1n ch\u1ec9 c\u1ea7n m\u1ed9t c\u00e2u tr\u1ea3 l\u1eddi ng\u1eafn: v\u1edbi VPS Linux th\u00f4ng th\u01b0\u1eddng, Nginx l\u00e0 l\u1ef1a ch\u1ecdn m\u1eb7c \u0111\u1ecbnh.<\/p>\n<table style=\"width: 100%; border-collapse: collapse; margin: 25px 0; font-size: 14px;\">\n<thead>\n<tr style=\"background-color: #1e3a8a; color: #fff;\">\n<th style=\"padding: 12px; border: 1px solid #BFDBFE; text-align: left;\">C\u00f4ng c\u1ee5<\/th>\n<th style=\"padding: 12px; border: 1px solid #BFDBFE; text-align: left;\">Hi\u1ec7u n\u0103ng<\/th>\n<th style=\"padding: 12px; border: 1px solid #BFDBFE; text-align: left;\">C\u1ea5u h\u00ecnh<\/th>\n<th style=\"padding: 12px; border: 1px solid #BFDBFE; text-align: left;\">Ph\u00f9 h\u1ee3p v\u1edbi<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background-color: #eff6ff;\">\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\"><strong>Nginx<\/strong><\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">Cao, event-driven, gi\u1eef \u0111\u01b0\u1ee3c h\u00e0ng ngh\u00ecn k\u1ebft n\u1ed1i \u0111\u1ed3ng th\u1eddi<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">File config d\u1ea1ng kh\u1ed1i, t\u00e0i li\u1ec7u nhi\u1ec1u<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">H\u1ea7u h\u1ebft d\u1ef1 \u00e1n web tr\u00ean VPS<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\"><strong>Apache mod_proxy<\/strong><\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">Th\u1ea5p h\u01a1n do m\u00f4 h\u00ecnh process\/thread<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\"><code>.htaccess<\/code> ho\u1eb7c virtual host<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">\u1ee8ng d\u1ee5ng PHP\/LAMP c\u0169 c\u1ea7n gi\u1eef stack<\/td>\n<\/tr>\n<tr style=\"background-color: #eff6ff;\">\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\"><strong>Caddy<\/strong><\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">Kh\u00e1, vi\u1ebft b\u1eb1ng Go, HTTPS t\u1ef1 \u0111\u1ed9ng qua ACME<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">Caddyfile ng\u1eafn, SSL t\u1ef1 lo<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">D\u1ef1 \u00e1n mu\u1ed1n HTTPS t\u1ef1 \u0111\u1ed9ng, ng\u1ea1i c\u1ea5u h\u00ecnh<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\"><strong>HAProxy<\/strong><\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">R\u1ea5t cao \u1edf t\u1ea7ng TCP\/L4, health check s\u00e2u<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">Config ri\u00eang, kh\u00f4ng ph\u1ea3i web server<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">H\u1ec7 th\u1ed1ng c\u1ea7n load balancing chuy\u00ean d\u1ee5ng<\/td>\n<\/tr>\n<tr style=\"background-color: #eff6ff;\">\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\"><strong>Traefik<\/strong><\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">Kh\u00e1, t\u1ef1 ph\u00e1t hi\u1ec7n service qua Docker\/K8s<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">Label tr\u00ean container<\/td>\n<td style=\"padding: 10px; border: 1px solid #E2E8F0;\">H\u1ea1 t\u1ea7ng container \u0111\u1ed9ng, microservices<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: justify;\">Caddy \u0111\u00e1ng c\u00e2n nh\u1eafc n\u1ebfu b\u1ea1n kh\u00f4ng mu\u1ed1n \u0111\u1ed9ng tay v\u00e0o ch\u1ee9ng ch\u1ec9 SSL. HAProxy ch\u1ec9 n\u00ean th\u00eam v\u00e0o khi Nginx kh\u00f4ng kham n\u1ed5i y\u00eau c\u1ea7u load balancing. Traefik h\u1ee3p v\u1edbi ai ch\u1ea1y nhi\u1ec1u container v\u00e0 mu\u1ed1n service t\u1ef1 \u0111\u0103ng k\u00fd. C\u00f2n l\u1ea1i, Nginx v\u1eabn l\u00e0 \u0111i\u1ec3m kh\u1edfi \u0111\u1ea7u an to\u00e0n.<\/p>\n<h2 id=\"section3\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">C\u1ea5u h\u00ecnh Nginx Reverse Proxy tr\u00ean Ubuntu \/ Debian<\/h2>\n<p style=\"text-align: justify;\">\u0110\u00e2y l\u00e0 ph\u1ea7n ch\u00ednh. N\u1ebfu ch\u01b0a c\u00f3 Nginx tr\u00ean m\u00e1y, b\u1ea1n xem tr\u01b0\u1edbc b\u00e0i <a href=\"https:\/\/interdata.vn\/blog\/cai-dat-nginx\/\">h\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t Nginx tr\u00ean Ubuntu<\/a> \u0111\u1ec3 n\u1eafm c\u00e1c b\u01b0\u1edbc c\u00e0i t\u1eeb repository. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 quy tr\u00ecnh \u0111\u1ea7y \u0111\u1ee7 t\u1eeb c\u00e0i \u0111\u1eb7t t\u1edbi reload config.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">B\u01b0\u1edbc 1. C\u00e0i Nginx v\u00e0 m\u1edf port 80, 443<\/h3>\n<pre><code class=\"language-bash\">sudo apt update\r\nsudo apt install -y nginx\r\nsudo systemctl enable --now nginx\r\nsudo ufw allow 80\/tcp\r\nsudo ufw allow 443\/tcp<\/code><\/pre>\n<p style=\"text-align: justify;\">Ki\u1ec3m tra Nginx \u0111\u00e3 ch\u1ea1y ch\u01b0a:<\/p>\n<pre><code class=\"language-bash\">sudo systemctl status nginx\r\ncurl -s http:\/\/localhost | head\r\n<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-43634\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/cai-dat-Nginx.png\" alt=\"c\u00e0i \u0111\u1eb7t Nginx\" width=\"800\" height=\"524\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/cai-dat-Nginx.png 1001w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/cai-dat-Nginx-300x197.png 300w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/cai-dat-Nginx-768x503.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">B\u01b0\u1edbc 2. T\u1ea1o server block reverse proxy<\/h3>\n<p style=\"text-align: justify;\">Tr\u00ean Ubuntu v\u00e0 Debian, file config n\u1eb1m trong <code>\/etc\/nginx\/sites-available\/<\/code>, sau \u0111\u00f3 symlink sang <code>\/etc\/nginx\/sites-enabled\/<\/code>. T\u1ea1o file m\u1edbi:<\/p>\n<pre><code class=\"language-bash\">sudo nano \/etc\/nginx\/sites-available\/app.example.com\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">D\u00e1n c\u1ea5u h\u00ecnh d\u01b0\u1edbi \u0111\u00e2y. Thay <code>app.example.com<\/code> b\u1eb1ng domain c\u1ee7a b\u1ea1n v\u00e0 <code>127.0.0.1:3000<\/code> b\u1eb1ng \u0111\u1ecba ch\u1ec9 backend:<\/p>\n<pre><code class=\"language-nginx\">server {\r\n    listen 80;\r\n    listen [::]:80;\r\n    server_name app.example.com;\r\n\r\n    location \/ {\r\n        proxy_pass http:\/\/127.0.0.1:3000;\r\n        proxy_http_version 1.1;\r\n\r\n        proxy_set_header Host $host;\r\n        proxy_set_header X-Real-IP $remote_addr;\r\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        proxy_set_header X-Forwarded-Proto $scheme;\r\n    }\r\n}\r\n<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-43635\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Tao-server-block-reverse-proxy.png\" alt=\"T\u1ea1o server block reverse proxy\" width=\"700\" height=\"370\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Tao-server-block-reverse-proxy.png 729w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Tao-server-block-reverse-proxy-300x158.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">B\u01b0\u1edbc 3. Enable site, ki\u1ec3m tra c\u00fa ph\u00e1p, reload<\/h3>\n<pre><code class=\"language-bash\">sudo ln -s \/etc\/nginx\/sites-available\/app.example.com \/etc\/nginx\/sites-enabled\/\r\nsudo nginx -t\r\nsudo systemctl reload nginx\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">Lu\u00f4n ch\u1ea1y <code>nginx -t<\/code> tr\u01b0\u1edbc khi reload. N\u1ebfu c\u00fa ph\u00e1p sai, Nginx t\u1eeb ch\u1ed1i n\u1ea1p config m\u1edbi nh\u01b0ng site \u0111ang ch\u1ea1y v\u1eabn s\u1ed1ng b\u00ecnh th\u01b0\u1eddng. Ch\u1ec9 khi n\u00e0o <code>nginx -t<\/code> b\u00e1o <code>syntax is ok<\/code> v\u00e0 <code>test is successful<\/code> th\u00ec l\u1ec7nh reload m\u1edbi th\u1eadt s\u1ef1 an to\u00e0n.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-43636\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/kiem-tra-cau-hinh-Nginx.png\" alt=\"ki\u1ec3m tra c\u1ea5u h\u00ecnh Nginx\" width=\"800\" height=\"119\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/kiem-tra-cau-hinh-Nginx.png 931w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/kiem-tra-cau-hinh-Nginx-300x45.png 300w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/kiem-tra-cau-hinh-Nginx-768x115.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">B\u1ea3ng t\u00f3m t\u1eaft c\u00e1c directive proxy_set_header quan tr\u1ecdng<\/h3>\n<table style=\"width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 14px;\">\n<thead>\n<tr style=\"background-color: #1e3a8a; color: #fff;\">\n<th style=\"padding: 10px; border: 1px solid #BFDBFE; text-align: left;\">Directive<\/th>\n<th style=\"padding: 10px; border: 1px solid #BFDBFE; text-align: left;\">Gi\u00e1 tr\u1ecb<\/th>\n<th style=\"padding: 10px; border: 1px solid #BFDBFE; text-align: left;\">T\u00e1c d\u1ee5ng<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background-color: #eff6ff;\">\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>proxy_set_header Host<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>$host<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\">Backend bi\u1ebft domain client g\u00f5 v\u00e0o, c\u1ea7n cho virtual host<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>proxy_set_header X-Real-IP<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>$remote_addr<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\">Backend nh\u1eadn IP th\u1eadt c\u1ee7a client<\/td>\n<\/tr>\n<tr style=\"background-color: #eff6ff;\">\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>proxy_set_header X-Forwarded-For<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>$proxy_add_x_forwarded_for<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\">Gi\u1eef chu\u1ed7i IP khi request \u0111i qua nhi\u1ec1u proxy, d\u00f9ng cho log<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>proxy_set_header X-Forwarded-Proto<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>$scheme<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\">Backend bi\u1ebft request g\u1ed1c l\u00e0 HTTP hay HTTPS<\/td>\n<\/tr>\n<tr style=\"background-color: #eff6ff;\">\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>proxy_set_header Upgrade<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>$http_upgrade<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\">B\u1eaft bu\u1ed9c \u0111\u1ec3 WebSocket ho\u1ea1t \u0111\u1ed9ng<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>proxy_set_header Connection<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\"><code>\"upgrade\"<\/code><\/td>\n<td style=\"padding: 8px; border: 1px solid #E2E8F0;\">Gi\u1eef k\u1ebft n\u1ed1i WebSocket m\u1edf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"section4\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">C\u1ea5u h\u00ecnh Nginx Reverse Proxy tr\u00ean CentOS \/ AlmaLinux \/ Rocky Linux<\/h2>\n<p style=\"text-align: justify;\">Tr\u00ean h\u1ecd RHEL, Nginx t\u1ef1 \u0111\u1ecdc m\u1ecdi file trong <code>\/etc\/nginx\/conf.d\/<\/code>, b\u1ea1n kh\u00f4ng c\u1ea7n symlink nh\u01b0 Ubuntu. Firewall m\u1eb7c \u0111\u1ecbnh l\u00e0 <code>firewalld<\/code> ch\u1ee9 kh\u00f4ng ph\u1ea3i UFW. Ba \u0111i\u1ec3m kh\u00e1c bi\u1ec7t ch\u00ednh c\u1ea7n nh\u1edb:<\/p>\n<ul>\n<li>Config \u0111\u1eb7t th\u1eb3ng \u1edf <code>\/etc\/nginx\/conf.d\/*.conf<\/code> v\u00e0 \u0111\u01b0\u1ee3c load t\u1ef1 \u0111\u1ed9ng.<\/li>\n<li>Kh\u00f4ng c\u00f3 b\u01b0\u1edbc symlink t\u1eeb sites-available sang sites-enabled.<\/li>\n<li>M\u1edf port b\u1eb1ng <code>firewall-cmd<\/code>, kh\u00f4ng d\u00f9ng <code>ufw<\/code>.<\/li>\n<\/ul>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">B\u01b0\u1edbc 1. C\u00e0i Nginx v\u00e0 m\u1edf firewall<\/h3>\n<pre><code class=\"language-bash\">sudo dnf install -y nginx\r\nsudo systemctl enable --now nginx\r\nsudo firewall-cmd --permanent --add-service=http\r\nsudo firewall-cmd --permanent --add-service=https\r\nsudo firewall-cmd --reload\r\n<\/code><\/pre>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">B\u01b0\u1edbc 2. T\u1ea1o file config trong conf.d<\/h3>\n<pre><code class=\"language-bash\">sudo nano \/etc\/nginx\/conf.d\/app.example.com.conf\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">N\u1ed9i dung config gi\u1ed1ng Ubuntu, ch\u1ec9 b\u1ecf b\u01b0\u1edbc symlink:<\/p>\n<pre><code class=\"language-nginx\">server {\r\n    listen 80;\r\n    listen [::]:80;\r\n    server_name app.example.com;\r\n\r\n    location \/ {\r\n        proxy_pass http:\/\/127.0.0.1:3000;\r\n        proxy_http_version 1.1;\r\n        proxy_set_header Host $host;\r\n        proxy_set_header X-Real-IP $remote_addr;\r\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        proxy_set_header X-Forwarded-Proto $scheme;\r\n    }\r\n}\r\n<\/code><\/pre>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">B\u01b0\u1edbc 3. Ki\u1ec3m tra v\u00e0 reload<\/h3>\n<pre><code class=\"language-bash\">sudo nginx -t\r\nsudo systemctl reload nginx\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">N\u1ebfu SELinux \u0111ang b\u1eadt (m\u1eb7c \u0111\u1ecbnh tr\u00ean CentOS, AlmaLinux, Rocky), Nginx c\u00f3 th\u1ec3 b\u1ecb ch\u1eb7n khi k\u1ebft n\u1ed1i ra backend port d\u00f9 config \u0111\u00fang. Ki\u1ec3m tra tr\u1ea1ng th\u00e1i v\u00e0 m\u1edf quy\u1ec1n:<\/p>\n<pre><code class=\"language-bash\">getenforce\r\nsudo setsebool -P httpd_can_network_connect 1\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">L\u1ec7nh <code>setsebool<\/code> \u1edf tr\u00ean cho ph\u00e9p Nginx th\u1ef1c hi\u1ec7n outbound connection. Kh\u00e1 nhi\u1ec1u b\u1ea1n m\u1ea5t c\u1ea3 bu\u1ed5i debug ch\u1ec9 v\u00ec thi\u1ebfu b\u01b0\u1edbc n\u00e0y.<\/p>\n<h2 id=\"section5\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">Use case 1: Nginx Reverse Proxy cho \u1ee9ng d\u1ee5ng Node.js v\u00e0 Python<\/h2>\n<p style=\"text-align: justify;\">\u0110\u00e2y l\u00e0 t\u00ecnh hu\u1ed1ng g\u1eb7p nhi\u1ec1u nh\u1ea5t: app Node.js ch\u1ea1y b\u1eb1ng PM2 tr\u00ean port 3000, Nginx nh\u1eadn request \u1edf port 80 r\u1ed3i chuy\u1ec3n v\u00e0o <code>127.0.0.1:3000<\/code>. N\u1ebfu m\u1edbi deploy l\u1ea7n \u0111\u1ea7u, b\u00e0i <a href=\"https:\/\/interdata.vn\/blog\/huong-dan-deploy-nodejs-tren-vps\/\">deploy Node.js tr\u00ean VPS v\u1edbi Nginx<\/a> \u0111i t\u1eeb c\u00e0i Node.js \u0111\u1ebfn PM2 v\u00e0 SSL.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">C\u1ea5u h\u00ecnh Nginx cho Node.js k\u00e8m WebSocket<\/h3>\n<p style=\"text-align: justify;\">\u1ee8ng d\u1ee5ng real-time nh\u01b0 chat, notification hay dashboard c\u1ea7n th\u00eam hai header <code>Upgrade<\/code> v\u00e0 <code>Connection<\/code>. Config \u0111\u1ea7y \u0111\u1ee7:<\/p>\n<pre><code class=\"language-nginx\">upstream nodejs_backend {\r\n    server 127.0.0.1:3000;\r\n    keepalive 64;\r\n}\r\n\r\nserver {\r\n    listen 80;\r\n    server_name app.example.com;\r\n\r\n    location \/ {\r\n        proxy_pass http:\/\/nodejs_backend;\r\n        proxy_http_version 1.1;\r\n\r\n        proxy_set_header Host $host;\r\n        proxy_set_header X-Real-IP $remote_addr;\r\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        proxy_set_header X-Forwarded-Proto $scheme;\r\n\r\n        proxy_set_header Upgrade $http_upgrade;\r\n        proxy_set_header Connection \"upgrade\";\r\n\r\n        proxy_read_timeout 3600s;\r\n        proxy_send_timeout 3600s;\r\n    }\r\n}\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">Hai timeout \u0111\u1eb7t cao (3600 gi\u00e2y) \u0111\u1ec3 WebSocket kh\u00f4ng b\u1ecb ng\u1eaft khi idle. N\u1ebfu \u0111\u1ec3 m\u1eb7c \u0111\u1ecbnh, k\u1ebft n\u1ed1i c\u00f3 th\u1ec3 b\u1ecb \u0111\u00f3ng sau 60 gi\u00e2y v\u00e0 client t\u1ef1 reconnect li\u00ean t\u1ee5c, log \u0111\u1ea7y l\u1ed7i tr\u00f4ng r\u1ea5t kh\u00f3 ch\u1ecbu.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">C\u1ea5u h\u00ecnh cho Python (Gunicorn \/ Uvicorn)<\/h3>\n<p style=\"text-align: justify;\">Django ho\u1eb7c Flask ch\u1ea1y qua Gunicorn \u1edf port 8000, FastAPI qua Uvicorn \u1edf port 8001, c\u1ea5u h\u00ecnh t\u01b0\u01a1ng t\u1ef1 Node.js nh\u01b0ng kh\u00f4ng c\u1ea7n header WebSocket n\u1ebfu app kh\u00f4ng d\u00f9ng:<\/p>\n<pre><code class=\"language-nginx\">server {\r\n    listen 80;\r\n    server_name api.example.com;\r\n\r\n    location \/ {\r\n        proxy_pass http:\/\/127.0.0.1:8000;\r\n        proxy_http_version 1.1;\r\n        proxy_set_header Host $host;\r\n        proxy_set_header X-Real-IP $remote_addr;\r\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        proxy_set_header X-Forwarded-Proto $scheme;\r\n\r\n        client_max_body_size 20m;\r\n    }\r\n}\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\"><code>client_max_body_size 20m<\/code> cho ph\u00e9p upload file t\u1edbi 20 MB. M\u1eb7c \u0111\u1ecbnh Nginx gi\u1edbi h\u1ea1n 1 MB, ai l\u00e0m ch\u1ee9c n\u0103ng upload th\u01b0\u1eddng d\u00ednh l\u1ed7i 413 Request Entity Too Large m\u00e0 kh\u00f4ng hi\u1ec3u t\u1ea1i sao.<\/p>\n<div style=\"background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%); border: 1.5px solid #2563EB; border-radius: 12px; padding: 28px; margin: 35px 0; text-align: center;\">\n<p style=\"font-family: 'Be Vietnam Pro', sans-serif; font-size: 22px; font-weight: bold; color: #1e3a8a; margin: 0 0 8px;\">S\u0103n \u01afu \u0110\u00e3i VPS Ti\u1ebft Ki\u1ec7m<\/p>\n<p style=\"font-size: 15px; color: #4b5563; margin-bottom: 20px;\">Canh Me t\u1ed5ng h\u1ee3p khuy\u1ebfn m\u00e3i, m\u00e3 gi\u1ea3m gi\u00e1, Hot Deals VPS v\u00e0 Cloud Server m\u1edbi nh\u1ea5t c\u1ee7a InterData. Xem qua tr\u01b0\u1edbc khi quy\u1ebft \u0111\u1ecbnh \u0111\u1ec3 ch\u1ecdn \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh h\u1ee3p t\u00fai ti\u1ec1n.<\/p>\n<p><a style=\"background: #2563EB; color: #fff; padding: 12px 30px; text-decoration: none; font-weight: 600; border-radius: 8px; display: inline-block;\" href=\"https:\/\/interdata.vn\/canhme\/\" target=\"_blank\" rel=\"noopener\">Xem Hot Deals T\u1ea1i Canh Me \u27f6<\/a><\/p>\n<\/div>\n<h2 id=\"section6\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">Use case 2: Nginx Reverse Proxy cho Docker Container<\/h2>\n<p style=\"text-align: justify;\">Khi \u1ee9ng d\u1ee5ng ch\u1ea1y trong Docker container, c\u00f3 hai c\u00e1ch \u0111\u1ec3 Nginx proxy t\u1edbi. C\u00e1ch th\u1ee9 nh\u1ea5t l\u00e0 map port container ra host r\u1ed3i proxy qua <code>localhost<\/code>. C\u00e1ch th\u1ee9 hai l\u00e0 cho Nginx v\u00e0 container v\u00e0o c\u00f9ng Docker network, proxy qua t\u00ean container.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">C\u00e1ch 1. Map port ra host (\u0111\u01a1n gi\u1ea3n nh\u1ea5t)<\/h3>\n<p style=\"text-align: justify;\">Ch\u1ea1y container v\u1edbi port mapping:<\/p>\n<pre><code class=\"language-bash\">docker run -d --name myapp -p 127.0.0.1:3000:3000 myapp:latest\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">\u0110\u1ec3 \u00fd d\u00f9ng <code>127.0.0.1:3000<\/code> thay v\u00ec <code>0.0.0.0:3000<\/code>. Port ch\u1ec9 bind v\u00e0o localhost, kh\u00f4ng l\u1ed9 ra ngo\u00e0i Internet. Nginx proxy qua <code>http:\/\/127.0.0.1:3000<\/code> gi\u1ed1ng h\u1ec7t tr\u01b0\u1eddng h\u1ee3p Node.js ch\u1ea1y tr\u1ef1c ti\u1ebfp tr\u00ean host.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">C\u00e1ch 2. Docker network (khi Nginx c\u0169ng ch\u1ea1y trong container)<\/h3>\n<p style=\"text-align: justify;\">N\u1ebfu Nginx ch\u1ea1y trong Docker, t\u1ea1o network chung r\u1ed3i proxy qua t\u00ean container:<\/p>\n<pre><code class=\"language-bash\">docker network create reverse_proxy\r\ndocker network connect reverse_proxy myapp\r\ndocker network connect reverse_proxy nginx_container\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">Config Nginx tr\u1ecf \u0111\u1ebfn t\u00ean container thay v\u00ec IP:<\/p>\n<pre><code class=\"language-nginx\">location \/ {\r\n    proxy_pass http:\/\/myapp:3000;\r\n    proxy_http_version 1.1;\r\n    proxy_set_header Host $host;\r\n    proxy_set_header X-Real-IP $remote_addr;\r\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n    proxy_set_header X-Forwarded-Proto $scheme;\r\n}\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">Docker DNS n\u1ed9i b\u1ed9 (th\u01b0\u1eddng l\u00e0 <code>127.0.0.11<\/code>) ph\u00e2n gi\u1ea3i t\u00ean <code>myapp<\/code> th\u00e0nh IP container. C\u00e1ch n\u00e0y \u1ed5n \u0111\u1ecbnh h\u01a1n d\u00f9ng IP v\u00ec IP container c\u00f3 th\u1ec3 \u0111\u1ed5i sau m\u1ed7i l\u1ea7n restart. Nh\u1edb th\u00eam <code>--restart unless-stopped<\/code> \u0111\u1ec3 container t\u1ef1 b\u1eadt l\u1ea1i khi VPS reboot:<\/p>\n<pre><code class=\"language-bash\">docker run -d --name myapp --restart unless-stopped \\\r\n  --network reverse_proxy myapp:latest\r\n<\/code><\/pre>\n<h2 id=\"section7\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">Th\u00eam SSL\/HTTPS v\u00e0 b\u1ea3o m\u1eadt n\u00e2ng cao cho Nginx Reverse Proxy<\/h2>\n<p style=\"text-align: justify;\">Sau khi reverse proxy HTTP ch\u1ea1y \u1ed5n, b\u01b0\u1edbc ti\u1ebfp theo l\u00e0 b\u1eadt HTTPS. Certbot v\u00e0 Let&#8217;s Encrypt cho ch\u1ee9ng ch\u1ec9 mi\u1ec5n ph\u00ed, t\u1ef1 gia h\u1ea1n. \u0110i\u1ec1u ki\u1ec7n \u0111\u1ec3 ch\u1ea1y Certbot: Nginx \u0111ang ch\u1ea1y v\u00e0 domain \u0111\u00e3 tr\u1ecf v\u1ec1 IP VPS.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">C\u00e0i Certbot v\u00e0 l\u1ea5y ch\u1ee9ng ch\u1ec9 SSL<\/h3>\n<pre><code class=\"language-bash\">sudo apt install -y certbot python3-certbot-nginx\r\nsudo certbot --nginx -d app.example.com\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">Certbot t\u1ef1 s\u1eeda file config Nginx, th\u00eam block <code>listen 443 ssl<\/code> v\u00e0 redirect HTTP sang HTTPS. Ki\u1ec3m tra t\u1ef1 \u0111\u1ed9ng gia h\u1ea1n:<\/p>\n<pre><code class=\"language-bash\">sudo certbot renew --dry-run\r\n<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-43144\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/08\/Certbot-homepage.png\" alt=\"Certbot homepage\" width=\"800\" height=\"387\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/08\/Certbot-homepage.png 1858w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/08\/Certbot-homepage-300x145.png 300w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/08\/Certbot-homepage-1024x495.png 1024w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/08\/Certbot-homepage-768x371.png 768w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/08\/Certbot-homepage-1536x742.png 1536w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">Th\u00eam security headers<\/h3>\n<p style=\"text-align: justify;\">Th\u00eam c\u00e1c header n\u00e0y v\u00e0o block <code>server<\/code> ch\u1ea1y HTTPS:<\/p>\n<pre><code class=\"language-nginx\">add_header X-Frame-Options \"SAMEORIGIN\" always;\r\nadd_header X-Content-Type-Options \"nosniff\" always;\r\nadd_header Strict-Transport-Security \"max-age=31536000; includeSubDomains\" always;\r\nadd_header Referrer-Policy \"strict-origin-when-cross-origin\" always;\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\"><code>X-Frame-Options<\/code> ch\u1ed1ng clickjacking. <code>X-Content-Type-Options<\/code> ng\u0103n tr\u00ecnh duy\u1ec7t t\u1ef1 \u0111o\u00e1n MIME type. <code>Strict-Transport-Security<\/code> bu\u1ed9c tr\u00ecnh duy\u1ec7t ch\u1ec9 d\u00f9ng HTTPS trong 1 n\u0103m. Kh\u00f4ng c\u00f3 HSTS, k\u1ebb t\u1ea5n c\u00f4ng c\u00f3 th\u1ec3 ch\u00e8n HTTP request tr\u01b0\u1edbc khi redirect k\u1ecbp x\u1ea3y ra.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">K\u1ebft h\u1ee3p UFW v\u00e0 Fail2ban<\/h3>\n<p style=\"text-align: justify;\">Ch\u1ec9 m\u1edf port 22, 80, 443 theo b\u00e0i <a href=\"https:\/\/interdata.vn\/blog\/ufw-la-gi\/\">c\u1ea5u h\u00ecnh UFW firewall tr\u00ean Ubuntu<\/a>. \u0110\u00f3ng h\u1ebft port n\u1ed9i b\u1ed9 (3000, 8000, 8080) kh\u1ecfi Internet. Sau \u0111\u00f3 <a href=\"https:\/\/interdata.vn\/blog\/cai-dat-fail2ban\/\">c\u00e0i \u0111\u1eb7t Fail2ban \u0111\u1ec3 ch\u1ed1ng brute-force<\/a> SSH v\u00e0 c\u00e1c endpoint \u0111\u0103ng nh\u1eadp:<\/p>\n<pre><code class=\"language-bash\">sudo apt install -y fail2ban\r\nsudo systemctl enable --now fail2ban\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">Fail2ban \u0111\u1ecdc log Nginx r\u1ed3i ban IP sau nhi\u1ec1u l\u1ea7n \u0111\u0103ng nh\u1eadp th\u1ea5t b\u1ea1i. N\u1ebfu ch\u1ea1y production, xem th\u00eam <a href=\"https:\/\/interdata.vn\/blog\/bao-mat-vps\/\">13 c\u00e1ch b\u1ea3o m\u1eadt VPS<\/a> \u0111\u1ec3 bi\u1ebft c\u00e1c l\u1edbp b\u1ea3o v\u1ec7 b\u1ed5 sung nh\u01b0 SSH key, \u0111\u1ed5i port SSH v\u00e0 gi\u00e1m s\u00e1t log \u0111\u1ecbnh k\u1ef3.<\/p>\n<div style=\"display: flex; flex-wrap: wrap; background-color: #fff; border: 1.5px solid #BFDBFE; box-shadow: 0 8px 20px rgba(37,99,235,0.08); border-radius: 12px; overflow: hidden; margin: 35px 0;\">\n<div style=\"flex: 1; min-width: 250px; background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%); display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center;\">\n<div>\n<p style=\"color: #fff; font-size: 34px; font-family: 'Be Vietnam Pro', sans-serif; font-weight: bold; margin: 0; line-height: 1.1;\">Cloud Server InterData<\/p>\n<p style=\"color: #dbeafe; font-size: 15px; font-weight: 600; margin-top: 12px;\">N\u00e2ng\/h\u1ea1 t\u00e0i nguy\u00ean nhanh theo t\u1ea3i, m\u1ea1ng t\u1ed1c \u0111\u1ed9 cao<\/p>\n<\/div>\n<\/div>\n<div style=\"flex: 2; padding: 25px; min-width: 300px;\">\n<h3 style=\"font-family: 'Be Vietnam Pro', sans-serif; color: #1e3a8a; margin-top: 0; font-size: 20px;\">H\u1ec7 th\u1ed1ng nhi\u1ec1u backend service c\u1ea7n h\u1ea1 t\u1ea7ng \u1ed5n \u0111\u1ecbnh h\u01a1n?<\/h3>\n<p style=\"text-align: justify; font-size: 15px; margin-bottom: 15px;\">Khi Nginx reverse proxy cho nhi\u1ec1u backend service c\u00f9ng l\u00fac, workload t\u0103ng \u0111\u1ed9t bi\u1ebfn, ho\u1eb7c c\u1ea3 team c\u00f9ng deploy chung m\u1ed9t m\u00f4i tr\u01b0\u1eddng production, Cloud Server InterData cho ph\u00e9p t\u0103ng CPU\/RAM m\u00e0 kh\u00f4ng ph\u1ea3i d\u1ef1ng l\u1ea1i Nginx t\u1eeb \u0111\u1ea7u. H\u1ee3p v\u1edbi ai c\u1ea7n ph\u00e2n t\u1ea3i qua block <code>upstream<\/code> nhi\u1ec1u node backend.<\/p>\n<p><a style=\"background: linear-gradient(90deg, #2563EB 0%, #1E3A8A 100%); color: #fff; padding: 12px 25px; text-decoration: none; font-weight: 600; border-radius: 8px; font-size: 15px; display: inline-block; box-shadow: 0 5px 15px rgba(37,99,235,0.3);\" href=\"https:\/\/interdata.vn\/cloud-server\/\" target=\"_blank\" rel=\"noopener\">Xem B\u1ea3ng Gi\u00e1 Cloud Server \u27f6<\/a><\/p>\n<\/div>\n<\/div>\n<h2 id=\"section8\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">X\u1eed l\u00fd l\u1ed7i th\u01b0\u1eddng g\u1eb7p khi c\u1ea5u h\u00ecnh Nginx Reverse Proxy<\/h2>\n<p style=\"text-align: justify;\">Ba l\u1ed7i d\u01b0\u1edbi \u0111\u00e2y chi\u1ebfm ph\u1ea7n l\u1edbn s\u1ef1 c\u1ed1 khi c\u1ea5u h\u00ecnh Nginx reverse proxy. M\u1ed7i l\u1ed7i s\u1ebd \u0111i k\u00e8m tri\u1ec7u ch\u1ee9ng, nguy\u00ean nh\u00e2n v\u00e0 l\u1ec7nh debug c\u1ee5 th\u1ec3 \u0111\u1ec3 b\u1ea1n ch\u1ea1y ngay.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">L\u1ed7i 502 Bad Gateway<\/h3>\n<p style=\"text-align: justify;\">Tri\u1ec7u ch\u1ee9ng l\u00e0 tr\u00ecnh duy\u1ec7t hi\u1ec7n 502, log Nginx c\u00f3 d\u00f2ng <code>upstream sent invalid header<\/code> ho\u1eb7c <code>connect() failed (111: Connection refused)<\/code>. Nguy\u00ean nh\u00e2n h\u1ea7u nh\u01b0 lu\u00f4n l\u00e0 backend kh\u00f4ng ch\u1ea1y tr\u00ean port Nginx proxy t\u1edbi, ho\u1eb7c backend v\u1eeba crash sau khi kh\u1edfi \u0111\u1ed9ng. Debug:<\/p>\n<pre><code class=\"language-bash\">curl -v http:\/\/127.0.0.1:3000\r\nsudo systemctl status myapp\r\nsudo journalctl -u myapp -n 50\r\nsudo tail -f \/var\/log\/nginx\/error.log\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">N\u1ebfu <code>curl<\/code> b\u00e1o <code>Connection refused<\/code>, backend ch\u01b0a ch\u1ea1y. V\u1edbi PM2 th\u00ec ki\u1ec3m tra <code>pm2 list<\/code> v\u00e0 <code>pm2 logs<\/code>. V\u1edbi Docker th\u00ec <code>docker ps<\/code> xem container c\u00f3 \u0111ang Up kh\u00f4ng.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">L\u1ed7i 504 Gateway Timeout<\/h3>\n<p style=\"text-align: justify;\">Request treo h\u01a1n 60 gi\u00e2y r\u1ed3i tr\u1ea3 504. Backend c\u00f3 th\u1ec3 v\u1eabn s\u1ed1ng nh\u01b0ng x\u1eed l\u00fd qu\u00e1 l\u00e2u. Th\u01b0\u1eddng g\u1eb7p v\u1edbi API g\u1ecdi database ch\u1eadm ho\u1eb7c ch\u1ee9c n\u0103ng xu\u1ea5t b\u00e1o c\u00e1o l\u1edbn. Ki\u1ec3m tra log xem request n\u00e0o timeout:<\/p>\n<pre><code class=\"language-bash\">sudo grep \"upstream timed out\" \/var\/log\/nginx\/error.log\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">T\u0103ng timeout trong block <code>location<\/code>:<\/p>\n<pre><code class=\"language-nginx\">proxy_connect_timeout 75s;\r\nproxy_send_timeout 300s;\r\nproxy_read_timeout 300s;\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">Ch\u1ec9 t\u0103ng timeout khi backend th\u1eadt s\u1ef1 c\u1ea7n th\u1eddi gian x\u1eed l\u00fd. N\u1ebfu request timeout li\u00ean t\u1ee5c, g\u1ed1c r\u1ec5 n\u1eb1m \u1edf backend, ph\u1ea3i t\u1ed1i \u01b0u query ho\u1eb7c th\u00eam cache. Khi c\u00f3 nhi\u1ec1u instance backend, c\u00e2n nh\u1eafc <a href=\"https:\/\/interdata.vn\/blog\/load-balancing-la-gi\/\">load balancing v\u1edbi Nginx<\/a> \u0111\u1ec3 chia request thay v\u00ec d\u1ed3n v\u00e0o m\u1ed9t node.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 20px; margin: 30px 0 15px;\">L\u1ed7i nginx: [emerg] bind() to 0.0.0.0:80 failed (permission denied)<\/h3>\n<p style=\"text-align: justify;\">Khi <code>systemctl start nginx<\/code> th\u1ea5t b\u1ea1i v\u1edbi d\u00f2ng <code>bind() to 0.0.0.0:80 failed (13: Permission denied)<\/code>, c\u00f3 hai kh\u1ea3 n\u0103ng. M\u1ed9t l\u00e0 ti\u1ebfn tr\u00ecnh Nginx ch\u1ea1y d\u01b0\u1edbi user kh\u00f4ng c\u00f3 quy\u1ec1n bind port d\u01b0\u1edbi 1024. Hai l\u00e0 port 80 \u0111\u00e3 b\u1ecb ph\u1ea7n m\u1ec1m kh\u00e1c chi\u1ebfm, th\u01b0\u1eddng l\u00e0 Apache. Ki\u1ec3m tra:<\/p>\n<pre><code class=\"language-bash\">sudo ss -tlnp | grep :80\r\n<\/code><\/pre>\n<p style=\"text-align: justify;\">N\u1ebfu Apache \u0111ang gi\u1eef port 80, d\u1eebng Apache: <code>sudo systemctl stop apache2<\/code>. N\u1ebfu Nginx b\u1ecb ch\u1ea1y b\u1eb1ng user th\u01b0\u1eddng, xem l\u1ea1i file <code>\/etc\/nginx\/nginx.conf<\/code>, d\u00f2ng <code>user nginx;<\/code> ph\u1ea3i \u0111\u1ec3 Nginx kh\u1edfi \u0111\u1ed9ng qua systemd (ch\u1ea1y root \u0111\u1ec3 bind port r\u1ed3i drop xu\u1ed1ng user nginx). \u0110\u1eebng ch\u1ea1y l\u1ec7nh <code>nginx<\/code> tr\u1ef1c ti\u1ebfp b\u1eb1ng user th\u01b0\u1eddng.<\/p>\n<div style=\"background-color: #f8fafc; border: 1.5px solid #E2E8F0; border-radius: 12px; padding: 30px; margin: 40px 0;\">\n<h2 style=\"color: #1e3a8a; font-size: 22px; font-weight: bold; margin-top: 0;\">C\u00e2u H\u1ecfi Th\u01b0\u1eddng G\u1eb7p v\u1ec1 C\u1ea5u H\u00ecnh Nginx Reverse Proxy<\/h2>\n<h3 style=\"color: #1e3a8a; font-size: 17px; margin: 20px 0 8px;\">Nginx Reverse Proxy kh\u00e1c g\u00ec Forward Proxy?<\/h3>\n<p style=\"text-align: justify;\">Forward Proxy \u0111\u1ee9ng v\u1ec1 ph\u00eda client, \u0111\u1ea1i di\u1ec7n client g\u1eedi request ra Internet v\u00e0 \u1ea9n IP client. Reverse Proxy \u0111\u1ee9ng v\u1ec1 ph\u00eda server, nh\u1eadn request r\u1ed3i chuy\u1ec3n v\u00e0o backend. Client ch\u1ec9 nh\u00ecn th\u1ea5y Nginx, kh\u00f4ng bi\u1ebft backend n\u1eb1m \u0111\u00e2u. Web production g\u1ea7n nh\u01b0 lu\u00f4n d\u00f9ng reverse proxy \u0111\u1ec3 b\u1ea3o v\u1ec7 backend v\u00e0 gom SSL v\u1ec1 m\u1ed9t ch\u1ed7.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 17px; margin: 20px 0 8px;\">Nginx Reverse Proxy c\u00f3 h\u1ed7 tr\u1ee3 WebSocket kh\u00f4ng?<\/h3>\n<p style=\"text-align: justify;\">C\u00f3, t\u1eeb Nginx 1.3.13. B\u1ea1n c\u1ea7n th\u00eam <code>proxy_set_header Upgrade $http_upgrade<\/code> v\u00e0 <code>proxy_set_header Connection \"upgrade\"<\/code> trong block <code>location<\/code>, k\u00e8m <code>proxy_http_version 1.1<\/code>. \u0110\u1eb7t th\u00eam <code>proxy_read_timeout<\/code> cao \u0111\u1ec3 k\u1ebft n\u1ed1i kh\u00f4ng b\u1ecb ng\u1eaft khi idle.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 17px; margin: 20px 0 8px;\">L\u1ed7i 502 Bad Gateway trong Nginx do \u0111\u00e2u v\u00e0 s\u1eeda nhanh th\u1ebf n\u00e0o?<\/h3>\n<p style=\"text-align: justify;\">502 x\u1ea3y ra khi Nginx kh\u00f4ng k\u1ebft n\u1ed1i \u0111\u01b0\u1ee3c backend. Nguy\u00ean nh\u00e2n ph\u1ed5 bi\u1ebfn nh\u1ea5t l\u00e0 backend ch\u01b0a ch\u1ea1y ho\u1eb7c v\u1eeba crash. Ki\u1ec3m tra b\u1eb1ng <code>curl http:\/\/127.0.0.1:PORT<\/code> v\u00e0 <code>sudo systemctl status t\u00ean-app<\/code>. Xem log \u1edf <code>\/var\/log\/nginx\/error.log<\/code> \u0111\u1ec3 bi\u1ebft chi ti\u1ebft.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 17px; margin: 20px 0 8px;\">Ch\u1ea1y nhi\u1ec1u domain tr\u00ean c\u00f9ng m\u1ed9t Nginx Reverse Proxy \u0111\u01b0\u1ee3c kh\u00f4ng?<\/h3>\n<p style=\"text-align: justify;\">\u0110\u01b0\u1ee3c. T\u1ea1o nhi\u1ec1u file config trong <code>\/etc\/nginx\/sites-available\/<\/code> (Ubuntu) ho\u1eb7c <code>\/etc\/nginx\/conf.d\/<\/code> (CentOS), m\u1ed7i file c\u00f3 <code>server_name<\/code> ri\u00eang v\u00e0 <code>proxy_pass<\/code> tr\u1ecf \u0111\u1ebfn backend t\u01b0\u01a1ng \u1ee9ng. Nginx d\u00f9ng <code>server_name<\/code> \u0111\u1ec3 route \u0111\u00fang domain. Nh\u1edb ch\u1ea1y <code>nginx -t<\/code> v\u00e0 reload sau khi th\u00eam.<\/p>\n<h3 style=\"color: #1e3a8a; font-size: 17px; margin: 20px 0 8px;\">Nginx Proxy Manager c\u00f3 t\u1ed1t h\u01a1n c\u1ea5u h\u00ecnh th\u1ee7 c\u00f4ng kh\u00f4ng?<\/h3>\n<p style=\"text-align: justify;\">Nginx Proxy Manager h\u1ee3p v\u1edbi ai mu\u1ed1n giao di\u1ec7n web \u0111\u1ec3 th\u00eam domain, b\u1eadt SSL v\u00e0 qu\u1ea3n l\u00fd proxy m\u00e0 kh\u00f4ng ph\u1ea3i s\u1eeda file config. C\u1ea5u h\u00ecnh th\u1ee7 c\u00f4ng cho quy\u1ec1n ki\u1ec3m so\u00e1t \u0111\u1ea7y \u0111\u1ee7, d\u1ec5 debug v\u00e0 kh\u00f4ng ph\u1ee5 thu\u1ed9c c\u00f4ng c\u1ee5 ngo\u00e0i. V\u1edbi sysadmin quen terminal, s\u1eeda file tr\u1ef1c ti\u1ebfp th\u01b0\u1eddng nhanh h\u01a1n.<\/p>\n<\/div>\n<div style=\"border-top: 2px dashed #BFDBFE; margin-top: 50px; padding-top: 30px;\">\n<h2 style=\"color: #1e3a8a; font-size: 22px; font-weight: bold;\">L\u1eddi k\u1ebft<\/h2>\n<p style=\"text-align: justify;\">\u0110\u1ebfn \u0111\u00e2y b\u1ea1n \u0111\u00e3 c\u00f3 \u0111\u1ee7 \u0111\u1ec3 c\u1ea5u h\u00ecnh Nginx Reverse Proxy cho h\u1ea7u h\u1ebft t\u00ecnh hu\u1ed1ng th\u01b0\u1eddng g\u1eb7p: t\u1ea1o server block v\u1edbi <code>proxy_pass<\/code>, x\u1eed l\u00fd WebSocket, proxy qua Docker container, b\u1eadt SSL b\u1eb1ng Certbot, th\u00eam security headers v\u00e0 debug l\u1ed7i 502\/504. Ba th\u1ee9 \u0111\u00e1ng nh\u1edb nh\u1ea5t: lu\u00f4n ch\u1ea1y <code>nginx -t<\/code> tr\u01b0\u1edbc khi reload, \u0111\u1eb7t <code>proxy_read_timeout<\/code> cao cho WebSocket, v\u00e0 gi\u1eef backend bind v\u00e0o <code>127.0.0.1<\/code> ch\u1ee9 \u0111\u1eebng bind v\u00e0o <code>0.0.0.0<\/code>. Vi\u1ec7c c\u00f2n l\u1ea1i l\u00e0 ki\u1ebfm m\u1ed9t VPS c\u00f3 quy\u1ec1n root \u0111\u1ec3 th\u1ef1c h\u00e0nh.<\/p>\n<div style=\"background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%); border-radius: 12px; padding: 30px; margin-top: 25px; text-align: center;\">\n<p style=\"font-family: 'Be Vietnam Pro', sans-serif; font-size: 22px; font-weight: bold; color: #fff; margin: 0 0 10px;\">S\u1eb5n s\u00e0ng th\u1ef1c h\u00e0nh c\u1ea5u h\u00ecnh Nginx Reverse Proxy?<\/p>\n<p style=\"color: #dbeafe; font-size: 15px; margin-bottom: 20px;\">VPS InterData v\u1edbi CPU th\u1ebf h\u1ec7 m\u1edbi, SSD NVMe U.2 v\u00e0 quy\u1ec1n root \u0111\u1ea7y \u0111\u1ee7 \u0111\u1ec3 b\u1ea1n c\u00e0i Nginx, th\u1eed reverse proxy v\u00e0 deploy \u1ee9ng d\u1ee5ng.<\/p>\n<p><a style=\"background: #fff; color: #1e3a8a; padding: 14px 35px; text-decoration: none; font-weight: bold; border-radius: 8px; font-size: 16px; display: inline-block;\" href=\"https:\/\/interdata.vn\/thue-vps\/\" target=\"_blank\" rel=\"noopener\">Xem C\u00e1c G\u00f3i VPS Gi\u00e1 T\u1ed1t \u27f6<\/a><\/p>\n<p style=\"margin-top: 15px;\"><a style=\"color: #dbeafe; font-size: 14px; text-decoration: underline;\" href=\"https:\/\/interdata.vn\/canhme\/\" target=\"_blank\" rel=\"noopener\">Ho\u1eb7c xem Hot Deals VPS &amp; Cloud Server t\u1ea1i Canh Me<\/a><\/p>\n<\/div>\n<\/div>\n<p style=\"text-align: justify; font-size: 13px; font-style: italic; color: #6b7280; margin-top: 30px; border-top: 1px solid #E5E7EB; padding-top: 15px;\"><em>N\u1ed9i dung mang t\u00ednh tham kh\u1ea3o. L\u1ec7nh, c\u00fa ph\u00e1p, \u0111\u01b0\u1eddng d\u1eabn file v\u00e0 t\u00f9y ch\u1ecdn c\u1ea5u h\u00ecnh c\u00f3 th\u1ec3 thay \u0111\u1ed5i theo phi\u00ean b\u1ea3n h\u1ec7 \u0111i\u1ec1u h\u00e0nh, phi\u00ean b\u1ea3n Nginx v\u00e0 m\u00f4i tr\u01b0\u1eddng c\u1ee5 th\u1ec3. N\u00ean ki\u1ec3m th\u1eed, sao l\u01b0u d\u1eef li\u1ec7u v\u00e0 \u0111\u00e1nh gi\u00e1 r\u1ee7i ro tr\u01b0\u1edbc khi \u00e1p d\u1ee5ng l\u00ean server production.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C\u1ea5u h\u00ecnh Nginx Reverse Proxy l\u00e0 vi\u1ec7c b\u1ea1n c\u1ea7n l\u00e0m khi \u0111\u00e3 deploy \u1ee9ng d\u1ee5ng Node.js, Python hay Docker l\u00ean VPS nh\u01b0ng kh\u00f4ng mu\u1ed1n m\u1edf th\u1eb3ng port n\u1ed9i b\u1ed9 ra Internet. Thay v\u00ec \u0111\u1ec3 ng\u01b0\u1eddi d\u00f9ng truy c\u1eadp IP:3000, b\u1ea1n cho h\u1ecd v\u00e0o domain qua port 80\/443, c\u00f2n Nginx \u0111\u1ee9ng gi\u1eefa chuy\u1ec3n ti\u1ebfp request v\u00e0o<\/p>\n","protected":false},"author":2,"featured_media":43637,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[161],"tags":[],"class_list":["post-43629","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-huong-dan-chung"],"_links":{"self":[{"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/posts\/43629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/comments?post=43629"}],"version-history":[{"count":7,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/posts\/43629\/revisions"}],"predecessor-version":[{"id":43641,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/posts\/43629\/revisions\/43641"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/media\/43637"}],"wp:attachment":[{"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/media?parent=43629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/categories?post=43629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/tags?post=43629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}