Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Run Node.js on a private loopback port and let Apache HTTP Server accept public requests, then reverse-proxy them to the Node process. A minimal setup uses ProxyRequests Off, ProxyPass, and ProxyPassReverse in an Apache virtual host. Apache 2.4.47 and later can pass WebSocket upgrades through mod_proxy_http; older releases require mod_proxy_wstunnel.

This arrangement gives you one public web server for hostnames, certificates, access logs, and multiple applications while Node remains reachable only through Apache.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How the reverse proxy works

The browser connects to Apache on the public address. Apache matches the request to a virtual host, forwards it to a Node.js process such as 127.0.0.1:3000, receives the response, and returns that response to the browser.

  • Node.js: listens on an application port, preferably on the loopback address.
  • Apache: listens on the public HTTP (and, if configured, HTTPS) port.
  • ProxyPass: maps a public URL path to the Node URL.
  • ProxyPassReverse: adjusts redirect-related response headers so redirects point to the public address.

Apache’s ProxyRequests setting is for forward-proxy behavior. It must remain off for this reverse-proxy arrangement; enabling it does not make reverse proxying work and can expose an unintended open proxy.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.

Before you configure Apache

Check that Node can serve requests locally

Start your application directly first. For example, if the project has a start script:

cd /var/www/my-node-app
npm ci
npm start

In a second shell, test the listening port:

curl http://127.0.0.1:3000/

Use the port your application actually listens on. If this local request fails, Apache cannot fix the application; inspect the Node process output and its own configuration first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prefer a loopback bind

Configure the application to listen on 127.0.0.1 (or another local-only address) when Apache is the intended public entry point. This prevents clients from bypassing Apache by connecting directly to the Node port. The exact setting depends on the framework; common Express-style code is:

app.listen(3000, '127.0.0.1');

If your app must listen on all interfaces for a specific deployment design, account for that separately with host-level firewall rules and authentication. Do not assume the proxy itself hides a publicly bound port.

Confirm Apache’s version

apache2ctl -v

The WebSocket configuration depends on whether the server is Apache 2.4.47 or newer. Keep the version output with your deployment notes.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Install Apache and enable proxy modules

On Ubuntu, install the distribution package if Apache is not already present:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update
sudo apt install apache2

Enable the core reverse-proxy modules:

sudo a2enmod proxy
sudo a2enmod proxy_http

If you will support WebSockets on Apache 2.4.46 or earlier, enable the WebSocket tunnel module as well:

sudo a2enmod proxy_wstunnel

Apache 2.4.47 and later can handle protocol upgrades through mod_proxy_http; mod_proxy_wstunnel is deprecated for that newer configuration. Module availability can vary by Ubuntu package, so treat an “already enabled” response as harmless and an “unknown module” response as a sign to check the installed Apache package and version.

Create the Apache virtual host

Basic HTTP proxy for one Node application

Create a site file such as /etc/apache2/sites-available/nodeapp.conf:

<VirtualHost *:80>
    ServerName example.com

    ProxyRequests Off
    ProxyPreserveHost Off

    ProxyPass        "/" "http://127.0.0.1:3000/"
    ProxyPassReverse "/" "http://127.0.0.1:3000/"
</VirtualHost>

Replace example.com with the hostname that resolves to this Ubuntu server and replace port 3000 with the port used by Node.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Why each directive is present

Directive Purpose Important behavior
ProxyRequests Off Disables forward-proxy requests. Reverse proxying does not require turning this on.
ProxyPreserveHost Off Uses the backend host defined by the proxy target instead of passing the browser’s original Host header. Off is Apache’s default and is normally appropriate.
ProxyPass Maps the public path to the Node origin. The first matching mapping is used; path-slash consistency matters.
ProxyPassReverse Rewrites redirect-related response headers from the backend. It changes Location, Content-Location, and URI headers, not HTML response bodies.

Trailing slashes must match

In the example, both mapping arguments end with /. Keep that pairing whenever you map a directory-like path: if the first argument ends in a slash, the second should too, and vice versa. Mismatched slashes can produce backend URLs that omit or duplicate a slash.

Enable the site

sudo a2ensite nodeapp.conf
sudo apache2ctl configtest
sudo systemctl reload apache2

Run configtest before every reload or restart. A successful result should report Syntax OK. If it reports an error, correct the named file and line instead of reloading a broken configuration.

Choose the correct WebSocket configuration

Apache 2.4.47 and newer: use an HTTP proxy upgrade

For an application whose WebSocket endpoint is /ws/, add a specific mapping with the upgrade parameter:

ProxyPass        "/ws/" "http://127.0.0.1:3000/ws/" upgrade=websocket
ProxyPassReverse "/ws/" "http://127.0.0.1:3000/ws/"
ProxyPass        "/"    "http://127.0.0.1:3000/"
ProxyPassReverse "/"    "http://127.0.0.1:3000/"

Put the WebSocket mapping before the broader HTTP mapping when both cover the same path. Apache evaluates the more specific route first in this arrangement; placing the catch-all first can send the upgrade request down the ordinary HTTP route.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The ProxyWebsocketFallbackToProxyHttp setting defaults to On; it controls whether the WebSocket tunnel module hands requests to the HTTP proxy implementation. You normally do not need to change it for the configuration above.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Apache 2.4.46 and earlier: use mod_proxy_wstunnel

Older Apache releases do not use the newer HTTP-upgrade form. Enable proxy_wstunnel and map the endpoint with the ws:// scheme:

ProxyPass        "/ws/" "ws://127.0.0.1:3000/ws/"
ProxyPassReverse "/ws/" "http://127.0.0.1:3000/ws/"
ProxyPass        "/"    "http://127.0.0.1:3000/"
ProxyPassReverse "/"    "http://127.0.0.1:3000/"

Keep the WebSocket rule ahead of the catch-all HTTP rule here as well. Do not copy the upgrade=websocket form to an older server without checking that release’s module support.

Host-header and URL-rewriting decisions

When to enable ProxyPreserveHost

ProxyPreserveHost is off by default and Apache documentation says it should normally stay off. Leave it off unless the backend specifically needs the original public Host header—for example, an application that selects tenants or generates canonical URLs from that header, or a proxied name-based virtual-host design.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If you do need it, set it explicitly inside the virtual host:

ProxyPreserveHost On

Changing this value can alter routing, absolute URL generation, and host-based security checks in the Node application. Test those behaviors after changing it.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

ProxyPassReverse does not rewrite page HTML

A backend redirect such as Location: http://127.0.0.1:3000/login can be adjusted by ProxyPassReverse. Absolute URLs embedded in an HTML body are different: they are not rewritten by that directive. If the application emits such markup and cannot be configured to use its public URL, Apache’s mod_proxy_html is the component intended for response-body rewriting. Prefer fixing the application’s public base URL when possible, because body rewriting adds another layer to maintain.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Run the Node process reliably

Apache only proxies to a process that is actually running. A terminal started with npm start is useful for a first test but will stop when the session ends. A common production pattern is a systemd service that runs the app as a non-root account, sets NODE_ENV=production, and restarts it after failure. The exact account, working directory, Node binary path, and environment variables are application-specific, so adapt the following example rather than copying it unchanged:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[Unit]
Description=Node application
After=network.target

[Service]
Type=simple
User=nodeapp
WorkingDirectory=/var/www/my-node-app
Environment=NODE_ENV=production
ExecStart=/usr/bin/node /var/www/my-node-app/server.js
Restart=always

[Install]
WantedBy=multi-user.target

Save it as /etc/systemd/system/nodeapp.service, then verify the paths and account before running:

sudo systemctl daemon-reload
sudo systemctl enable --now nodeapp
sudo systemctl status nodeapp
curl http://127.0.0.1:3000/

If your application is launched through npm, use the appropriate npm command or an absolute path to the Node executable supplied by your installation. Check journalctl -u nodeapp when the service exits.

Test the complete path

  1. Confirm the Node service is listening locally with curl http://127.0.0.1:3000/.
  2. Run sudo apache2ctl configtest and resolve every syntax error.
  3. Reload Apache with sudo systemctl reload apache2.
  4. From the server, request the public hostname: curl -i http://example.com/. The response should come from the Node application through Apache.
  5. Test a route that redirects, if your app has one, and verify that the Location header uses the public URL rather than the loopback address.
  6. If using WebSockets, connect to the exact endpoint (for example, /ws/) with your client and watch both application and Apache logs during the handshake.

Troubleshoot failures by symptom

Apache returns 502 Bad Gateway or 503

  • Check that the Node process is running and listening on the configured port.
  • Compare the address in ProxyPass with the address the app actually binds to. An app bound only to a different interface will not accept a request sent to 127.0.0.1.
  • Read the Apache error log and the Node service log together; connection-refused messages usually indicate a stopped process or wrong port.

Apache serves its default page

  • Verify that the request hostname matches ServerName.
  • Confirm the site is enabled and reload succeeded.
  • Disable or adjust a competing virtual host only after confirming which host Apache selected.

Redirects expose the internal port

  • Ensure ProxyPassReverse uses the same public and backend path pair as ProxyPass.
  • Remember that it rewrites response headers, not HTML links or JavaScript strings.
  • Configure the Node application’s public base URL if it generates absolute links.

WebSocket handshake fails or returns an HTTP redirect

  • Confirm the Apache version and use the matching configuration: upgrade=websocket on 2.4.47 and newer, or mod_proxy_wstunnel with ws:// on 2.4.46 and earlier.
  • Place the WebSocket ProxyPass before the general HTTP mapping.
  • Check that the client uses the correct /ws/ path and that Node exposes the same path.
  • Inspect Apache’s error log and the Node application’s handshake log. A direct WebSocket connection working while the proxied one fails does not, by itself, identify the cause; verify route order, module support, and redirects.

Only some paths fail

Compare trailing slashes in both arguments of each mapping and look for overlapping path rules. A narrow route should appear before a catch-all route, and the backend path must match what the Node router expects.

Configuration checklist

  • Node responds successfully on its local port before Apache is involved.
  • The application is bound to loopback when Apache is the intended public entry point.
  • ProxyRequests Off is present.
  • ProxyPass and ProxyPassReverse point to the same backend path and use matching slash conventions.
  • ProxyPreserveHost remains off unless the application has a documented need for the original host header.
  • WebSocket rules match the Apache version and precede a broader HTTP rule.
  • apache2ctl configtest reports Syntax OK before reload.
  • Apache and Node logs are available for diagnosing connection, routing, and upgrade errors.

What this setup does—and does not—provide

This design separates the public HTTP endpoint from the Node listener and lets Apache route by hostname and path. It does not automatically manage the Node process, rewrite arbitrary HTML, or make an incorrectly configured WebSocket endpoint work. Treat process supervision, application URL generation, TLS policy, and authentication as separate configuration concerns.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.